Skip to content

Commit

Permalink
shared: refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagokokada committed Oct 11, 2023
1 parent 330cee5 commit ef53eed
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 43 deletions.
5 changes: 4 additions & 1 deletion home-manager/meta/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
# sudo echo "trusted-users = @wheel" >> /etc/nix/nix.conf
nix = {
package = lib.mkDefault pkgs.nix;
settings = import ../../shared/nix-conf.nix // (import ../../shared/cachix.nix);
settings = lib.mkMerge [
(import ../../shared/nix-conf.nix)
(import ../../shared/substituters.nix)
];
};

# Set custom nixpkgs config (e.g.: allowUnfree), both for this
Expand Down
58 changes: 33 additions & 25 deletions nixos/nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,34 +22,42 @@ in
nom-rebuild
];

nix = lib.mkMerge [
(import ../../shared/nix.nix { inherit pkgs flake; })
{
gc = {
automatic = true;
persistent = true;
randomizedDelaySec = "15m";
dates = "3:15";
options = "--delete-older-than 7d";
};
# Reduce disk usage
daemonIOSchedClass = "idle";
# Leave nix builds as a background task
daemonCPUSchedPolicy = "idle";
}
{
settings =
let
cachix = import ../../shared/cachix.nix;
in
nix = {
gc = {
automatic = true;
persistent = true;
randomizedDelaySec = "15m";
dates = "3:15";
options = "--delete-older-than 7d";
};
# Reduce disk usage
daemonIOSchedClass = "idle";
# Leave nix builds as a background task
daemonCPUSchedPolicy = "idle";

# Set the $NIX_PATH entry for nixpkgs. This is necessary in
# this setup with flakes, otherwise commands like `nix-shell
# -p pkgs.htop` will keep using an old version of nixpkgs
nixPath = [
"nixpkgs=${flake}"
];
# Same as above, but for `nix shell nixpkgs#htop`
registry.nixpkgs.flake = flake;

settings =
let
substituters = import ../../shared/substituters.nix;
in
lib.mkMerge [
(import ../../shared/nix-conf.nix)
{
# For some reason when nix is running as daemon,
# extra-{substituters,trusted-public-keys} doesn't work
substituters = [ "https://cache.nixos.org/" ] ++ cachix.extra-substituters;
trusted-public-keys = cachix.extra-trusted-public-keys;
};
}
];
substituters = substituters.extra-substituters;
trusted-public-keys = substituters.extra-trusted-public-keys;
}
];
};

# Enable unfree packages
nixpkgs.config.allowUnfree = true;
Expand Down
17 changes: 0 additions & 17 deletions shared/nix.nix

This file was deleted.

File renamed without changes.

0 comments on commit ef53eed

Please sign in to comment.