Use flake-utils-plus

This commit is contained in:
Charlotte Van Petegem 2021-03-24 11:07:32 +01:00
parent 809457c8f9
commit eb385040a7
No known key found for this signature in database
GPG key ID: 019E764B7184435A
3 changed files with 53 additions and 62 deletions

36
flake.lock generated
View file

@ -27,7 +27,6 @@
},
"original": {
"owner": "numtide",
"ref": "master",
"repo": "flake-utils",
"type": "github"
}
@ -54,16 +53,16 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1616250371,
"narHash": "sha256-bG3/Dt3f/x8qUZ6djnfUVG8erVzwA9I4pxrtzmCizoI=",
"owner": "chvp",
"lastModified": 1616527350,
"narHash": "sha256-VkMevY2WLU+K7T/P4wVj18Ms8zyeRfp05ILf556m5Y8=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "e132ddfecfeba08f3b09b72064ded55b9fceb45a",
"rev": "d3f7e969b9860fb80750147aeb56dab1c730e756",
"type": "github"
},
"original": {
"owner": "chvp",
"ref": "master",
"owner": "nixos",
"ref": "nixos-unstable-small",
"repo": "nixpkgs",
"type": "github"
}
@ -71,9 +70,28 @@
"root": {
"inputs": {
"emacs-overlay": "emacs-overlay",
"flake-utils": "flake-utils",
"home-manager": "home-manager",
"nixpkgs": "nixpkgs"
"nixpkgs": "nixpkgs",
"utils": "utils"
}
},
"utils": {
"inputs": {
"flake-utils": "flake-utils"
},
"locked": {
"lastModified": 1616328024,
"narHash": "sha256-t5FrJlYiN1HojtN3eRWlPhmzH2+5pdB22AfosbphI6c=",
"owner": "gytis-ivaskevicius",
"repo": "flake-utils-plus",
"rev": "51cb739c9c9c2258bc70747eb7bc22975ae244bd",
"type": "github"
},
"original": {
"owner": "gytis-ivaskevicius",
"ref": "master",
"repo": "flake-utils-plus",
"type": "github"
}
}
},

View file

@ -3,53 +3,36 @@
inputs = {
emacs-overlay.url = "github:nix-community/emacs-overlay/master";
flake-utils.url = "github:numtide/flake-utils/master";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
nixpkgs.url = "github:chvp/nixpkgs/master";
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable-small";
utils.url = "github:gytis-ivaskevicius/flake-utils-plus/master";
};
outputs = { self, emacs-overlay, nixpkgs, home-manager, flake-utils }:
let
version-suffix = nixpkgs.rev or (builtins.toString nixpkgs.lastModified);
pkgsFor = system: import nixpkgs {
inherit system;
};
mkSystem = system: hostname: nixpkgs.lib.nixosSystem {
inherit system;
modules = [
({ pkgs, ... }: { nixpkgs.overlays = [ emacs-overlay.overlay ]; })
home-manager.nixosModules.home-manager
(./modules)
(./. + "/machines/${hostname}")
({ pkgs, ... }: {
environment.etc."nixpkgs".source = (pkgs.runCommandNoCC "nixpkgs" { } ''
cp -r ${nixpkgs} $out
chmod 700 $out
echo "${version-suffix}" > $out/.version-suffix
'');
nix.nixPath = [ "nixpkgs=/etc/nixpkgs" ];
})
];
};
in
flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = pkgsFor system;
in
{
devShell = pkgs.mkShell {
buildInputs = with pkgs; [ nixpkgs-fmt ];
};
}) // {
nixosConfigurations = {
kharbranth = mkSystem "x86_64-linux" "kharbranth";
kholinar = mkSystem "x86_64-linux" "kholinar";
lasting-integrity = mkSystem "x86_64-linux" "lasting-integrity";
urithiru = mkSystem "x86_64-linux" "urithiru";
};
outputs = inputs@{ self, nixpkgs, emacs-overlay, home-manager, utils }: utils.lib.systemFlake {
inherit self inputs;
channels.nixpkgs = {
input = nixpkgs;
patches = [ ];
# TODO: Try to find a way to get rid of this and return to the
# list built up in the config.
config = { allowUnfree = true; };
};
sharedOverlays = [ emacs-overlay.overlay ];
sharedModules = [
utils.nixosModules.saneFlakeDefaults
home-manager.nixosModules.home-manager
./modules
];
nixosProfiles = {
kharbranth = { system = "x86_64-linux"; modules = [ ./machines/kharbranth ]; };
kholinar = { system = "x86_64-linux"; modules = [ ./machines/kholinar ]; };
lasting-integrity = { system = "x86_64-linux"; modules = [ ./machines/lasting-integrity ]; };
urithiru = { system = "x86_64-linux"; modules = [ ./machines/urithiru ]; };
};
devShellBuilder = channels:
let pkgs = channels.nixpkgs; in pkgs.mkShell { buildInputs = [ pkgs.nixpkgs-fmt ]; };
};
}

View file

@ -43,10 +43,6 @@ in
default = true;
example = false;
};
enableFlakes = lib.mkOption {
default = true;
example = false;
};
unfreePackages = lib.mkOption {
default = [ ];
example = [ "teams" ];
@ -82,17 +78,11 @@ in
'' + (lib.optionalString config.chvp.nix.enableDirenv ''
keep-outputs = true
keep-derivations = true
'') + (lib.optionalString config.chvp.nix.enableFlakes ''
experimental-features = nix-command flakes
'');
};
nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) config.chvp.nix.unfreePackages;
nixpkgs.overlays = lib.mkIf config.chvp.nix.enableFlakes [
(self: super: {
nix = super.nixUnstable;
})
];
nixpkgs.overlays = [ (self: super: { nix = super.nixUnstable; }) ];
home-manager.users.charlotte = { ... }:
lib.recursiveUpdate