Upgrade flake with pre-commit hooks and devShell

This commit is contained in:
2026-03-28 23:18:52 +01:00
parent 20913e8a21
commit 5637b6188f
4 changed files with 126 additions and 10 deletions

1
.envrc Normal file
View File

@@ -0,0 +1 @@
use flake

10
.gitignore vendored
View File

@@ -1,2 +1,8 @@
# "nix build" default output symlink # direnv cache
/result /.direnv
# "nix build" default output link
result
# nix pre-commit autogenerated by devShell
/.pre-commit-config.yaml

78
flake.lock generated
View File

@@ -53,9 +53,25 @@
"type": "github" "type": "github"
} }
}, },
"flake-compat_2": {
"flake": false,
"locked": {
"lastModified": 1767039857,
"narHash": "sha256-vNpUSpF5Nuw8xvDLj2KCwwksIbjua2LZCqhV1LNRDns=",
"owner": "NixOS",
"repo": "flake-compat",
"rev": "5edf11c44bc78a0d334f6334cdaf7d60d732daab",
"type": "github"
},
"original": {
"owner": "NixOS",
"repo": "flake-compat",
"type": "github"
}
},
"flake-utils": { "flake-utils": {
"inputs": { "inputs": {
"systems": "systems_2" "systems": "systems_3"
}, },
"locked": { "locked": {
"lastModified": 1681202837, "lastModified": 1681202837,
@@ -116,6 +132,28 @@
"type": "github" "type": "github"
} }
}, },
"git-hooks_2": {
"inputs": {
"flake-compat": "flake-compat_2",
"gitignore": "gitignore_2",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1774104215,
"narHash": "sha256-EAtviqz0sEAxdHS4crqu7JGR5oI3BwaqG0mw7CmXkO8=",
"owner": "cachix",
"repo": "git-hooks.nix",
"rev": "f799ae951fde0627157f40aec28dec27b22076d0",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "git-hooks.nix",
"type": "github"
}
},
"gitignore": { "gitignore": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@@ -138,6 +176,27 @@
"type": "github" "type": "github"
} }
}, },
"gitignore_2": {
"inputs": {
"nixpkgs": [
"git-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1709087332,
"narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"home-manager": { "home-manager": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@@ -212,10 +271,12 @@
"inputs": { "inputs": {
"darwin": "darwin", "darwin": "darwin",
"fw_nix": "fw_nix", "fw_nix": "fw_nix",
"git-hooks": "git-hooks_2",
"home-manager": "home-manager", "home-manager": "home-manager",
"nix-homebrew": "nix-homebrew", "nix-homebrew": "nix-homebrew",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"nixpkgs-screen": "nixpkgs-screen", "nixpkgs-screen": "nixpkgs-screen",
"systems": "systems_2",
"vscode-server": "vscode-server" "vscode-server": "vscode-server"
} }
}, },
@@ -249,6 +310,21 @@
"type": "github" "type": "github"
} }
}, },
"systems_3": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"vscode-server": { "vscode-server": {
"inputs": { "inputs": {
"flake-utils": "flake-utils", "flake-utils": "flake-utils",

View File

@@ -8,6 +8,7 @@
# - background colors in programs (eg less) not showing # - background colors in programs (eg less) not showing
# - caption and hardstatus color lacks intensity # - caption and hardstatus color lacks intensity
nixpkgs-screen.url = "github:NixOS/nixpkgs/e518d4ad2bcad74f98fec028cf21ce5b1e5020dd"; nixpkgs-screen.url = "github:NixOS/nixpkgs/e518d4ad2bcad74f98fec028cf21ce5b1e5020dd";
systems.url = "github:nix-systems/default";
home-manager = { home-manager = {
url = "github:nix-community/home-manager"; url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
@@ -25,12 +26,17 @@
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
nix-homebrew.url = "github:zhaofengli/nix-homebrew"; nix-homebrew.url = "github:zhaofengli/nix-homebrew";
git-hooks = {
url = "github:cachix/git-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
}; };
outputs = outputs =
{ {
self, self,
nixpkgs, nixpkgs,
systems,
home-manager, home-manager,
vscode-server, vscode-server,
darwin, darwin,
@@ -42,8 +48,18 @@
"ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBJhQjxeLZUWdEPMqPNS8wTTrg4lbzBAOLKvdsJd0fSBcW5ILuEbKQjgEIwmYuR/iGhnqIp7rQK48xL/4CauQUyg= office-dock-usb-a" "ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBJhQjxeLZUWdEPMqPNS8wTTrg4lbzBAOLKvdsJd0fSBcW5ILuEbKQjgEIwmYuR/iGhnqIp7rQK48xL/4CauQUyg= office-dock-usb-a"
"ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBJg7zQ4H0LQeQcILZBwCzQ+MYKtCgKm7HPe9oFeoyprKZXAvpm+HDHtaYdU39JF9f+nvRztzXuMhgETAQMAQCkc= fingerprint@macbook" "ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBJg7zQ4H0LQeQcILZBwCzQ+MYKtCgKm7HPe9oFeoyprKZXAvpm+HDHtaYdU39JF9f+nvRztzXuMhgETAQMAQCkc= fingerprint@macbook"
]; ];
eachSystem = nixpkgs.lib.genAttrs (import systems);
in in
{ {
checks = eachSystem (system: {
pre-commit-check = inputs.git-hooks.lib.${system}.run (
{
src = ./.;
}
// inputs.fw_nix.lib.pre-commit
);
});
homeModules.main = { homeModules.main = {
imports = [ ./modules/home.nix ]; imports = [ ./modules/home.nix ];
}; };
@@ -73,13 +89,16 @@
inputs.fw_nix.nixosModules.nix-settings inputs.fw_nix.nixosModules.nix-settings
inputs.fw_nix.nixosModules.futureware inputs.fw_nix.nixosModules.futureware
inputs.nix-homebrew.darwinModules.nix-homebrew inputs.nix-homebrew.darwinModules.nix-homebrew
({ lib, ... }: { (
# TODO: find solution to these ugly workarounds { lib, ... }:
options.programs.htop = lib.mkOption { {
type = lib.types.deferredModule; # TODO: find solution to these ugly workarounds
default = { }; options.programs.htop = lib.mkOption {
}; type = lib.types.deferredModule;
}) default = { };
};
}
)
./hosts/mars/darwin.nix ./hosts/mars/darwin.nix
]; ];
}; };
@@ -105,5 +124,19 @@
./hosts/deimos/nixos.nix ./hosts/deimos/nixos.nix
]; ];
}; };
devShells = eachSystem (
system:
let
pkgs = import nixpkgs { inherit system; };
inherit (self.checks.${system}.pre-commit-check) shellHook enabledPackages;
in
{
default = pkgs.mkShell {
packages = enabledPackages;
inherit shellHook;
};
}
);
}; };
} }