Skip to content

Commit

Permalink
Extract duplicated nix configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
rake5k committed Jan 3, 2024
1 parent b0686ad commit 42b6a03
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 57 deletions.
1 change: 1 addition & 0 deletions lib/builders/mkNixDarwin.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ inputs.darwin.lib.darwinSystem {
};

modules = [
./modules/nix
inputs.home-manager.darwinModules.home-manager
"${inputs.self}/hosts/${name}"

Expand Down
1 change: 1 addition & 0 deletions lib/builders/mkNixos.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ inputs.nixpkgs.lib.nixosSystem {
};

modules = [
./modules/nix
"${inputs.self}/hosts/${name}"

{
Expand Down
36 changes: 36 additions & 0 deletions lib/builders/modules/nix/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{ pkgs, config, lib, inputs, ... }:

{
nix = {
nixPath = [ "nixpkgs=flake:nixpkgs" ];
registry = {
nixpkgs.flake = inputs.nixpkgs;
nix-config.flake = inputs.self;
};
settings = {
allowed-users = builtins.attrNames config.users.users;
auto-optimise-store = true;
experimental-features = [ "nix-command" "flakes" ];
log-lines = 30;
substituters = [
"https://christianharke.cachix.org/"
"https://nix-community.cachix.org"
"https://cache.nixos.org"
];
trusted-public-keys = [
"christianharke.cachix.org-1:TzmbiNLRcH8G0932XRlQzh8GPvuV9pJcHLqLnzznLKU="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
];
};
};

system.activationScripts.diff = {
supportsDryActivation = true;
text = ''
if [[ -e /run/current-system ]]; then
${lib.getExe pkgs.nix} store diff-closures /run/current-system "$systemConfig"
fi
'';
};
}
28 changes: 0 additions & 28 deletions nix-darwin/nix/default.nix
Original file line number Diff line number Diff line change
@@ -1,37 +1,9 @@
{ pkgs, config, lib, inputs, ... }:

{
# TODO: Extract duplications from nixos config
nix = {
nixPath = [ "nixpkgs=flake:nixpkgs" ];
registry = {
nixpkgs.flake = inputs.nixpkgs;
nix-config.flake = inputs.self;
};
settings = {
allowed-users = builtins.attrNames config.users.users;
auto-optimise-store = true;
experimental-features = [ "nix-command" "flakes" ];
log-lines = 30;
substituters = [
"https://christianharke.cachix.org/"
"https://nix-community.cachix.org"
"https://cache.nixos.org"
];
trusted-public-keys = [
"christianharke.cachix.org-1:TzmbiNLRcH8G0932XRlQzh8GPvuV9pJcHLqLnzznLKU="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
];
};
};

system.activationScripts.diff = {
supportsDryActivation = true;
text = ''
if [[ -e /run/current-system ]]; then
${lib.getExe pkgs.nix} store diff-closures /run/current-system "$systemConfig"
fi
'';
};
}
29 changes: 0 additions & 29 deletions nixos/base/nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,6 @@
dates = "04:00";
options = "--delete-older-than 7d";
};
nixPath = [ "nixpkgs=flake:nixpkgs" ];
optimise.automatic = true;
registry = {
nixpkgs.flake = inputs.nixpkgs;
nix-config.flake = inputs.self;
};
settings = {
allowed-users = builtins.attrNames config.users.users;
experimental-features = [ "nix-command" "flakes" ];
log-lines = 30;
substituters = [
"https://christianharke.cachix.org/"
"https://nix-community.cachix.org"
"https://cache.nixos.org"
];
trusted-public-keys = [
"christianharke.cachix.org-1:TzmbiNLRcH8G0932XRlQzh8GPvuV9pJcHLqLnzznLKU="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
];
};
};

system.activationScripts.diff = {
supportsDryActivation = true;
text = ''
if [[ -e /run/current-system ]]; then
${lib.getExe pkgs.nix} store diff-closures /run/current-system "$systemConfig"
fi
'';
};
}

0 comments on commit 42b6a03

Please sign in to comment.