Skip to content

Commit

Permalink
fix: nix-path, registry
Browse files Browse the repository at this point in the history
  • Loading branch information
konradmalik committed Aug 14, 2024
1 parent 7f2f036 commit 5d2e4f0
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 34 deletions.
7 changes: 7 additions & 0 deletions hosts/common/modules/nix/not-hm.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{ inputs, ... }:
{
# should be >= max-jobs
nix.nrBuildUsers = 16;
# Make `nix repl '<nixpkgs>'` use the same nixpkgs as the one used by this flake.
environment.etc."nix/inputs/nixpkgs".source = "${inputs.nixpkgs}";
}
72 changes: 38 additions & 34 deletions hosts/common/modules/nix/shared.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
{
config,
pkgs,
lib,
inputs,
...
}:
let
isHomeManager = builtins.hasAttr "hm" lib;
in
{
imports = lib.optionals (!isHomeManager) [ ./not-hm.nix ];

nixpkgs = {
overlays = [
(
Expand All @@ -25,38 +29,38 @@
permittedInsecurePackages = [ ];
};
};
nix =
{
package = pkgs.nixVersions.latest;
settings = {
auto-optimise-store = lib.mkDefault true;
experimental-features = [
"nix-command"
"flakes"
];
keep-derivations = true;
keep-outputs = true;
trusted-users =
[ "root" ]
++ lib.optional pkgs.stdenvNoCC.isLinux "@wheel" ++ lib.optional pkgs.stdenvNoCC.isDarwin "@admin";
extra-substituters = [
"https://konradmalik.cachix.org"
"https://nix-community.cachix.org"
];
extra-trusted-public-keys = [
"konradmalik.cachix.org-1:9REXmCYRwPNL0kAB0IMeTxnMB1Gl9VY5I8w7UVBTtSI="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs"
];
min-free = lib.mkDefault (10 * 1000 * 1000 * 1000); # 10gb
cores = lib.mkDefault 0;
max-jobs = lib.mkDefault "auto";
};
}
# below does not exist in plain home-manager
# but it will work for nixos config and for nix-darwin config
# this check is needed because of generic linux entry in homeConfigurations
// lib.optionalAttrs (builtins.hasAttr "nrBuildUsers" config.nix) {
# should be >= max-jobs
nrBuildUsers = 16;
nix = {
package = pkgs.nixVersions.latest;
# make `nix run nixpkgs#nixpkgs` use the same nixpkgs as the one used by this flake.
registry = {
nixpkgs.flake = inputs.nixpkgs;
nixpkgs-stable.flake = inputs.nixpkgs-stable;
};
settings = {
# NIX_PATH is still used by many useful tools, so we set it to the same value as the one used by this flake.
# https://github.com/NixOS/nix/issues/9574
nix-path = lib.mkForce "nixpkgs=/etc/nix/inputs/nixpkgs";
auto-optimise-store = lib.mkDefault true;
experimental-features = [
"nix-command"
"flakes"
];
keep-derivations = true;
keep-outputs = true;
trusted-users =
[ "root" ]
++ lib.optional pkgs.stdenvNoCC.isLinux "@wheel" ++ lib.optional pkgs.stdenvNoCC.isDarwin "@admin";
extra-substituters = [
"https://konradmalik.cachix.org"
"https://nix-community.cachix.org"
];
extra-trusted-public-keys = [
"konradmalik.cachix.org-1:9REXmCYRwPNL0kAB0IMeTxnMB1Gl9VY5I8w7UVBTtSI="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs"
];
min-free = lib.mkDefault (10 * 1000 * 1000 * 1000); # 10gb
cores = lib.mkDefault 0;
max-jobs = lib.mkDefault "auto";
};
};
}

0 comments on commit 5d2e4f0

Please sign in to comment.