2024-01-06 01:19:35 +01:00
|
|
|
# SPDX-FileCopyrightText: 2020-2023 Simon Bruder <simon@sbruder.de>
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
|
2021-05-15 10:04:44 +02:00
|
|
|
{ config, inputs, lib, pkgs, ... }:
|
2021-04-09 11:34:49 +02:00
|
|
|
let
|
2021-05-01 16:30:48 +02:00
|
|
|
# Adapted from https://nixos.wiki/wiki/Overlays
|
2021-04-09 11:34:49 +02:00
|
|
|
overlaysCompat = pkgs.writeTextFile {
|
|
|
|
name = "overlays-compat";
|
|
|
|
destination = "/overlays.nix";
|
2021-08-05 13:23:07 +02:00
|
|
|
text = /* nix */ ''
|
2021-04-09 11:34:49 +02:00
|
|
|
self: super:
|
|
|
|
with super.lib;
|
|
|
|
let
|
|
|
|
# Load the system config and get the `nixpkgs.overlays` option
|
2021-05-01 16:30:48 +02:00
|
|
|
# This fails gracefully if getFlake is not available
|
2023-09-20 22:11:54 +02:00
|
|
|
overlays = if (builtins.hasAttr "getFlake" builtins && builtins.pathExists "/var/src/config")
|
2021-05-01 16:30:48 +02:00
|
|
|
then (builtins.getFlake "/var/src/config").nixosConfigurations.${config.networking.hostName}.config.nixpkgs.overlays
|
|
|
|
else [ ];
|
2021-04-09 11:34:49 +02:00
|
|
|
in
|
|
|
|
# Apply all overlays to the input of the current "main" overlay
|
|
|
|
foldl' (flip extends) (_: super) overlays self
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
in
|
|
|
|
{
|
|
|
|
nix = {
|
2021-05-15 10:04:44 +02:00
|
|
|
registry = with inputs; {
|
|
|
|
nixpkgs.flake = nixpkgs;
|
|
|
|
nixpkgs-unstable.flake = nixpkgs-unstable;
|
|
|
|
};
|
|
|
|
|
2021-04-09 11:34:49 +02:00
|
|
|
nixPath = [
|
2021-05-15 10:04:44 +02:00
|
|
|
"nixpkgs=${inputs.nixpkgs}"
|
2021-04-09 11:34:49 +02:00
|
|
|
"nixpkgs-overlays=${overlaysCompat}"
|
|
|
|
];
|
|
|
|
|
2022-12-10 16:08:13 +01:00
|
|
|
settings = {
|
|
|
|
# Make sudoers trusted nix users
|
|
|
|
trusted-users = [ "@wheel" ];
|
|
|
|
|
|
|
|
# On-the-fly optimisation of nix store
|
|
|
|
auto-optimise-store = true;
|
|
|
|
|
|
|
|
experimental-features = "nix-command flakes";
|
|
|
|
} // (lib.optionalAttrs config.sbruder.full {
|
2021-04-09 11:34:49 +02:00
|
|
|
# Keep output of derivations with gc root
|
2022-12-10 16:08:13 +01:00
|
|
|
keep-outputs = true;
|
|
|
|
keep-derivations = true;
|
|
|
|
});
|
2021-12-06 16:00:41 +01:00
|
|
|
|
2021-04-09 11:34:49 +02:00
|
|
|
# Make nix build in background less noticeable
|
2021-11-20 16:29:48 +01:00
|
|
|
daemonCPUSchedPolicy = "batch";
|
|
|
|
daemonIOSchedPriority = 5; # 0-7
|
2021-12-06 16:00:41 +01:00
|
|
|
};
|
2021-05-15 10:04:44 +02:00
|
|
|
|
|
|
|
nixpkgs.overlays = with inputs; [
|
2022-06-23 19:03:58 +02:00
|
|
|
self.overlays.default
|
2023-12-02 18:54:23 +01:00
|
|
|
nixpkgs-overlay.overlays.default
|
2021-05-15 10:04:44 +02:00
|
|
|
(final: prev: {
|
|
|
|
unstable = import nixpkgs-unstable {
|
|
|
|
inherit (config.nixpkgs)
|
|
|
|
config
|
|
|
|
overlays
|
|
|
|
system;
|
|
|
|
};
|
|
|
|
})
|
|
|
|
];
|
2021-07-11 10:43:43 +02:00
|
|
|
|
|
|
|
environment.systemPackages = with pkgs; [
|
|
|
|
cached-nix-shell
|
|
|
|
];
|
2021-04-09 11:34:49 +02:00
|
|
|
}
|