Use flakes
This commit is contained in:
parent
dbac505917
commit
f5730508de
9 changed files with 172 additions and 12 deletions
64
flake.nix
Normal file
64
flake.nix
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
{
|
||||
inputs = {
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-21.05";
|
||||
|
||||
nix-pre-commit-hooks = {
|
||||
url = "github:cachix/pre-commit-hooks.nix/master";
|
||||
inputs.flake-utils.follows = "flake-utils";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
outputs =
|
||||
{ self
|
||||
, nixpkgs
|
||||
, flake-utils
|
||||
, nix-pre-commit-hooks
|
||||
, ...
|
||||
}@inputs: flake-utils.lib.eachDefaultSystem
|
||||
(system:
|
||||
let
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
inherit (pkgs) lib;
|
||||
in
|
||||
{
|
||||
checks = {
|
||||
pre-commit-check = nix-pre-commit-hooks.lib.${system}.run {
|
||||
src = self;
|
||||
hooks = {
|
||||
black.enable = true;
|
||||
nixpkgs-fmt.enable = true;
|
||||
shellcheck.enable = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
devShell = pkgs.mkShell {
|
||||
buildInputs = (with pkgs; [
|
||||
black
|
||||
nixpkgs-fmt
|
||||
shellcheck
|
||||
]);
|
||||
|
||||
shellHook = ''
|
||||
${self.checks.${system}.pre-commit-check.shellHook}
|
||||
'';
|
||||
};
|
||||
}) // {
|
||||
nixosConfigurations = nixpkgs.lib.mapAttrs
|
||||
(hostname: { system
|
||||
, extraModules ? [ ]
|
||||
, nixpkgs ? inputs.nixpkgs
|
||||
}: nixpkgs.lib.nixosSystem rec {
|
||||
inherit system;
|
||||
|
||||
modules = [
|
||||
(./machines + "/${hostname}/configuration.nix")
|
||||
|
||||
{
|
||||
_module.args.inputs = inputs;
|
||||
}
|
||||
] ++ extraModules;
|
||||
})
|
||||
(import ./machines inputs);
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue