nix: add sensible nix config
This commit is contained in:
parent
0553edb906
commit
e32e07a7d9
3 changed files with 80 additions and 3 deletions
|
|
@ -1,5 +1,63 @@
|
|||
{ pkgs, ... }:
|
||||
|
||||
{ config, inputs, pkgs, ... }:
|
||||
let
|
||||
# Adapted from https://nixos.wiki/wiki/Overlays
|
||||
overlaysCompat = pkgs.writeTextFile {
|
||||
name = "overlays-compat";
|
||||
destination = "/overlays.nix";
|
||||
text = ''
|
||||
self: super:
|
||||
with super.lib;
|
||||
let
|
||||
# Load the system config and get the `nixpkgs.overlays` option
|
||||
# This fails gracefully if getFlake is not available
|
||||
overlays = if builtins.hasAttr "getFlake" builtins
|
||||
then (builtins.getFlake "/var/src/config").nixosConfigurations.${config.networking.hostName}.config.nixpkgs.overlays
|
||||
else [ ];
|
||||
in
|
||||
# Apply all overlays to the input of the current "main" overlay
|
||||
foldl' (flip extends) (_: super) overlays self
|
||||
'';
|
||||
};
|
||||
in
|
||||
{
|
||||
nix.package = pkgs.nixUnstable;
|
||||
nix = {
|
||||
# flake support
|
||||
package = pkgs.nixUnstable;
|
||||
|
||||
extraOptions = ''
|
||||
experimental-features = nix-command flakes
|
||||
'';
|
||||
|
||||
registry = with inputs; {
|
||||
nixpkgs.flake = nixpkgs;
|
||||
nixpkgs-unstable.flake = nixpkgs-unstable;
|
||||
};
|
||||
nixPath = [
|
||||
"nixpkgs=${inputs.nixpkgs}"
|
||||
"nixpkgs-overlays=${overlaysCompat}"
|
||||
];
|
||||
|
||||
# sudoers are trusted nix users
|
||||
trustedUsers = [ "@wheel" ];
|
||||
|
||||
# On-the-fly optimisation of nix store
|
||||
autoOptimiseStore = true;
|
||||
|
||||
# less noticeable nix builds
|
||||
daemonNiceLevel = 10;
|
||||
daemonIONiceLevel = 5;
|
||||
};
|
||||
|
||||
nixpkgs.overlays = with inputs; [
|
||||
self.overlay
|
||||
|
||||
(final: prev: {
|
||||
unstable = import nixpkgs-unstable {
|
||||
inherit (config.nixpkgs)
|
||||
config
|
||||
overlays
|
||||
system;
|
||||
};
|
||||
})
|
||||
];
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue