From a0afcb130531bb8b820932f35c3e33894a2e43a8 Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Tue, 10 Dec 2024 00:45:52 +0900 Subject: [PATCH] Update flake to nixos-24.11 and install selfup in devshell --- .github/workflows/ci-js.yml | 2 +- .github/workflows/lint.yml | 4 +- .../workflows/update-flake-lock-and-ci.yml | 2 +- .vscode/settings.json | 2 +- flake.lock | 52 +++----- flake.nix | 115 ++++++++++++------ package.json | 1 + 7 files changed, 102 insertions(+), 76 deletions(-) diff --git a/.github/workflows/ci-js.yml b/.github/workflows/ci-js.yml index 4cf5bf58..1f687dae 100644 --- a/.github/workflows/ci-js.yml +++ b/.github/workflows/ci-js.yml @@ -38,7 +38,7 @@ jobs: - uses: actions/checkout@v4 - uses: denoland/setup-deno@v2 with: - deno-version: '1.44.3' # selfup {"extract":"\\d[^']+","replacer":["bash","-c","deno --version | head -n 1"], "nth": 2} + deno-version: '2.1.2' # selfup {"extract":"\\d[^']+","replacer":["bash","-c","deno --version | head -n 1"], "nth": 2} - run: deno lint stylelint: timeout-minutes: 15 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 72e820a4..bcf08562 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -11,13 +11,13 @@ jobs: - uses: actions/checkout@v4 - uses: dprint/check@v2.2 with: - dprint-version: '0.45.1' # selfup { "extract": "\\d[^']+", "replacer": ["dprint", "--version"], "nth": 2 } + dprint-version: '0.47.2' # selfup { "extract": "\\d[^']+", "replacer": ["dprint", "--version"], "nth": 2 } typos: timeout-minutes: 15 runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 - - uses: crate-ci/typos@v1.21.0 # selfup { "extract": "\\d\\.\\d+\\.\\d+", "replacer": ["typos", "--version"], "nth": 2 } + - uses: crate-ci/typos@v1.27.3 # selfup { "extract": "\\d\\.\\d+\\.\\d+", "replacer": ["typos", "--version"], "nth": 2 } with: # https://github.com/crate-ci/typos/issues/779#issuecomment-1635741586 files: | diff --git a/.github/workflows/update-flake-lock-and-ci.yml b/.github/workflows/update-flake-lock-and-ci.yml index 09adcb66..e1e66071 100644 --- a/.github/workflows/update-flake-lock-and-ci.yml +++ b/.github/workflows/update-flake-lock-and-ci.yml @@ -11,7 +11,7 @@ on: jobs: update-nixpkgs: - uses: kachick/selfup/.github/workflows/reusable-bump-flake-lock-and-selfup.yml@v1.1.7 + uses: kachick/selfup/.github/workflows/reusable-bump-flake-lock-and-selfup.yml@v1.1.8 with: app_id: ${{ vars.DEPENDENCY_APP_ID }} dry-run: ${{ github.event_name == 'pull_request' }} diff --git a/.vscode/settings.json b/.vscode/settings.json index 33c96cbf..94ec4847 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -13,7 +13,7 @@ "nix.serverSettings": { "nil": { "formatting": { - "command": ["nixpkgs-fmt"] + "command": ["nixfmt"] } } }, diff --git a/flake.lock b/flake.lock index c8e5eee3..fa591f98 100644 --- a/flake.lock +++ b/flake.lock @@ -1,57 +1,45 @@ { "nodes": { - "flake-utils": { - "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1731533236, - "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, "nixpkgs": { "locked": { - "lastModified": 1733384649, - "narHash": "sha256-K5DJ2LpPqht7K76bsxetI+YHhGGRyVteTPRQaIIKJpw=", + "lastModified": 1733550349, + "narHash": "sha256-NcGumB4Lr6KSDq+nIqXtNA8QwAQKDSZT7N9OTGWbTrs=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "190c31a89e5eec80dd6604d7f9e5af3802a58a13", + "rev": "e2605d0744c2417b09f8bf850dfca42fcf537d34", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-24.05", + "ref": "nixos-24.11", "repo": "nixpkgs", "type": "github" } }, "root": { "inputs": { - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "selfup": "selfup" } }, - "systems": { + "selfup": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "lastModified": 1733754336, + "narHash": "sha256-Sy4LfPXqa2CKnySCFTLMwU5mSKxKOdeC52Yjoomcbvs=", + "owner": "kachick", + "repo": "selfup", + "rev": "ecb158813e7ade0a2e9b88b186460d052a906f20", "type": "github" }, "original": { - "owner": "nix-systems", - "repo": "default", + "owner": "kachick", + "ref": "v1.1.8", + "repo": "selfup", "type": "github" } } diff --git a/flake.nix b/flake.nix index 2b5365fd..8bb87f62 100644 --- a/flake.nix +++ b/flake.nix @@ -5,52 +5,89 @@ # - https://discourse.nixos.org/t/differences-between-nix-channels/13998 # How to update the revision # - `nix flake update --commit-lock-file` # https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-flake-update.html - nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05"; - flake-utils.url = "github:numtide/flake-utils"; + nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11"; + selfup = { + url = "github:kachick/selfup/v1.1.8"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; - outputs = { self, nixpkgs, flake-utils }: - flake-utils.lib.eachDefaultSystem (system: - let - pkgs = nixpkgs.legacyPackages.${system}; - in - { - devShells.default = with pkgs; - mkShell { - buildInputs = [ - # https://github.com/NixOS/nix/issues/730#issuecomment-162323824 - bashInteractive + outputs = + { + self, + nixpkgs, + selfup, + }: + let + inherit (nixpkgs) lib; + # List: https://github.com/NixOS/nixpkgs/blob/nixos-24.05/lib/systems/flake-systems.nix + # + # https://github.com/NixOS/nixpkgs/blob/475556854559746466df20d74eef189373816b67/flake.nix?plain=1#L11 + # https://github.com/NixOS/nixpkgs/blob/475556854559746466df20d74eef189373816b67/lib/systems/default.nix?plain=1#L48-L56 + forAllSystems = lib.genAttrs lib.systems.flakeExposed; + in + { + formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.nixfmt-rfc-style); + devShells = forAllSystems ( + system: + let + pkgs = nixpkgs.legacyPackages.${system}; + in + { + default = pkgs.mkShellNoCC { + buildInputs = + (with pkgs; [ + # https://github.com/NixOS/nix/issues/730#issuecomment-162323824 + # https://github.com/kachick/dotfiles/pull/228 + bashInteractive + findutils # xargs + nixfmt-rfc-style + nil - nil - nixpkgs-fmt - dprint - nodejs_20 - elmPackages.elm-json - deno - typos - ]; + nodejs_20 + elmPackages.elm-json + deno + + dprint + typos + ]) + ++ [ selfup.packages.${system}.default ]; }; + } + ); - apps = { + apps = forAllSystems ( + system: + let + pkgs = nixpkgs.legacyPackages.${system}; + in + { bump-nix-dependencies = { type = "app"; - program = with pkgs; lib.getExe (writeShellApplication { - name = "bump-nix-dependencies.bash"; - runtimeInputs = [ nix git nodejs_20 sd ]; - # Why --really-refresh?: https://stackoverflow.com/q/34807971 - text = '' - set -x + program = + with pkgs; + lib.getExe (writeShellApplication { + name = "bump-nix-dependencies.bash"; + runtimeInputs = [ + nix + git + nodejs_20 + sd + ]; + # Why --really-refresh?: https://stackoverflow.com/q/34807971 + text = '' + set -x - node --version | sd '^v?' "" > .node-version && git add .node-version - git update-index -q --really-refresh - git diff-index --quiet HEAD || git commit -m 'Sync .node-version with nixpkgs' .node-version - ''; - meta = { - description = "Bump dependency versions except managed by node package manager"; - }; - }); + node --version | sd '^v?' "" > .node-version && git add .node-version + git update-index -q --really-refresh + git diff-index --quiet HEAD || git commit -m 'Sync .node-version with nixpkgs' .node-version + ''; + meta = { + description = "Bump dependency versions except managed by node package manager"; + }; + }); }; - }; - } - ); + } + ); + }; } diff --git a/package.json b/package.json index 6d41596d..eefdbadc 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "stylelint:check": "npx stylelint '{src,public}/**/*.css'", "stylelint:fix": "npx stylelint '{src,public}/**/*.css' --fix", "typecheck": "tsc", + "selfup": "git ls-files '.github' | xargs selfup run", "deps": "nix --version && dprint --version && typos --version && node --version && npm --version && deno --version && elm --version && elm-json --version" }, "author": "Kenichi Kamiya ",