Skip to content

Commit

Permalink
Update flake to nixos-24.11 and install selfup in devshell
Browse files Browse the repository at this point in the history
  • Loading branch information
kachick committed Dec 9, 2024
1 parent 5d03412 commit a0afcb1
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 76 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ jobs:
- uses: actions/checkout@v4
- uses: dprint/[email protected]
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: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-flake-lock-and-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:

jobs:
update-nixpkgs:
uses: kachick/selfup/.github/workflows/[email protected].7
uses: kachick/selfup/.github/workflows/[email protected].8
with:
app_id: ${{ vars.DEPENDENCY_APP_ID }}
dry-run: ${{ github.event_name == 'pull_request' }}
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"nix.serverSettings": {
"nil": {
"formatting": {
"command": ["nixpkgs-fmt"]
"command": ["nixfmt"]
}
}
},
Expand Down
52 changes: 20 additions & 32 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

115 changes: 76 additions & 39 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
};
});
};
};
}
);
}
);
};
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>",
Expand Down

0 comments on commit a0afcb1

Please sign in to comment.