nix-config/flake.nix

175 lines
3.9 KiB
Nix
Raw Normal View History

2021-02-05 16:25:39 +01:00
{
2021-03-07 19:30:33 +01:00
description = "NixOS configuration with flakes";
2021-02-05 16:25:39 +01:00
inputs = {
2021-09-25 13:30:51 +02:00
agenix = {
type = "github";
owner = "ryantm";
repo = "agenix";
ref = "main";
2021-09-25 13:30:51 +02:00
inputs = {
nixpkgs.follows = "nixpkgs";
};
};
futils = {
type = "github";
owner = "numtide";
repo = "flake-utils";
ref = "master";
};
home-manager = {
type = "github";
owner = "nix-community";
repo = "home-manager";
ref = "master";
inputs = {
nixpkgs.follows = "nixpkgs";
2022-06-22 11:19:43 +02:00
utils.follows = "futils";
};
};
nixpkgs = {
type = "github";
owner = "NixOS";
repo = "nixpkgs";
ref = "nixos-unstable";
};
nur = {
type = "github";
owner = "nix-community";
repo = "NUR";
ref = "master";
};
pre-commit-hooks = {
type = "github";
owner = "cachix";
repo = "pre-commit-hooks.nix";
ref = "master";
inputs = {
flake-utils.follows = "futils";
nixpkgs.follows = "nixpkgs";
nixpkgs-stable.follows = "nixpkgs";
};
};
2021-02-05 16:25:39 +01:00
};
2021-05-31 23:01:21 +02:00
outputs =
inputs @
{ self
2021-09-25 13:30:51 +02:00
, agenix
2021-05-31 23:01:21 +02:00
, futils
, home-manager
, nixpkgs
, nur
, pre-commit-hooks
2021-05-31 23:01:21 +02:00
}:
2021-02-18 21:19:11 +01:00
let
inherit (futils.lib) eachSystem system;
mySystems = [
system.aarch64-linux
system.x86_64-darwin
system.x86_64-linux
];
eachMySystem = eachSystem mySystems;
lib = nixpkgs.lib.extend (self: super: {
my = import ./lib { inherit inputs; pkgs = nixpkgs; lib = self; };
});
defaultModules = [
2021-03-08 19:59:08 +01:00
({ ... }: {
# Let 'nixos-version --json' know about the Git revision
system.configurationRevision = self.rev or "dirty";
})
{
nixpkgs.overlays = (lib.attrValues self.overlays) ++ [
nur.overlay
];
}
# Include generic settings
./modules
# Include bundles of settings
./profiles
];
buildHost = name: system: lib.nixosSystem {
2021-02-18 21:19:11 +01:00
inherit system;
modules = defaultModules ++ [
(./. + "/machines/${name}")
2021-02-05 16:25:39 +01:00
];
specialArgs = {
# Use my extended lib in NixOS configuration
inherit lib;
# Inject inputs to use them in global registry
inherit inputs;
};
2021-02-18 21:19:11 +01:00
};
in
eachMySystem
(system:
2021-05-31 23:01:21 +02:00
let
pkgs = nixpkgs.legacyPackages.${system};
in
rec {
apps = {
diff-flake = futils.lib.mkApp { drv = packages.diff-flake; };
2022-05-31 13:41:42 +02:00
default = apps.diff-flake;
2021-05-31 23:01:21 +02:00
};
checks = {
pre-commit = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
nixpkgs-fmt = {
enable = true;
};
shellcheck = {
enable = true;
};
};
};
};
devShells = {
default = pkgs.mkShell {
name = "NixOS-config";
nativeBuildInputs = with pkgs; [
gitAndTools.pre-commit
nixpkgs-fmt
];
inherit (self.checks.${system}.pre-commit) shellHook;
};
2021-05-31 23:01:21 +02:00
};
2021-06-12 19:55:54 +02:00
packages =
let
inherit (futils.lib) filterPackages flattenTree;
2021-06-12 19:55:54 +02:00
packages = import ./pkgs { inherit pkgs; };
flattenedPackages = flattenTree packages;
finalPackages = filterPackages system flattenedPackages;
2021-06-12 19:55:54 +02:00
in
finalPackages;
2021-05-31 23:01:21 +02:00
}) // {
2021-05-09 00:06:12 +02:00
overlays = import ./overlays // {
lib = final: prev: { inherit lib; };
pkgs = final: prev: {
ambroisie = prev.recurseIntoAttrs (import ./pkgs { pkgs = prev; });
};
};
nixosConfigurations = lib.mapAttrs buildHost {
2021-04-02 14:00:21 +02:00
aramis = "x86_64-linux";
2021-02-18 21:19:11 +01:00
porthos = "x86_64-linux";
};
2021-02-05 16:25:39 +01:00
};
}