117 lines
3.6 KiB
Nix
117 lines
3.6 KiB
Nix
{
|
|
config,
|
|
host,
|
|
inputs,
|
|
lib,
|
|
pkgs,
|
|
user,
|
|
dots,
|
|
system,
|
|
...
|
|
}:
|
|
|
|
{
|
|
environment = {
|
|
# for nixlang / nixpkgs
|
|
systemPackages = with pkgs; [
|
|
nix-init
|
|
nix-update
|
|
nixfmt-rfc-style
|
|
];
|
|
};
|
|
|
|
custom.shell.packages = {
|
|
# list all installed packages
|
|
nix-list-packages = {
|
|
text =
|
|
let
|
|
allPkgs = map (p: p.name) (
|
|
config.environment.systemPackages ++ config.users.users.${user}.packages ++ config.hm.home.packages
|
|
);
|
|
in
|
|
''sort -ui <<< "${lib.concatLines allPkgs}"'';
|
|
};
|
|
};
|
|
|
|
nix =
|
|
let
|
|
flakeInputs = lib.filterAttrs (_: lib.isType "flake") inputs;
|
|
nixPath = lib.mapAttrsToList (n: _: "${n}=flake:${n}") flakeInputs;
|
|
in
|
|
{
|
|
inherit nixPath;
|
|
enable = true;
|
|
channel.enable = false;
|
|
optimise.automatic = true; # Optimise symlinks
|
|
# required for nix-shell -p to work
|
|
registry = lib.mapAttrs (_: flake: { inherit flake; }) flakeInputs;
|
|
# gc = {
|
|
# # Automatic garbage collection
|
|
# automatic = true;
|
|
# dates = "daily";
|
|
# options = "--delete-older-than 7d";
|
|
# };
|
|
package = pkgs.nixVersions.latest;
|
|
settings = {
|
|
# re-evaluate on every rebuild instead of "cached failure of attribute" error
|
|
# eval-cache = false;
|
|
# required to be set, for some reason nix.nixPath does not write to nix.conf
|
|
nix-path = nixPath;
|
|
warn-dirty = false;
|
|
# removes ~/.nix-profile and ~/.nix-defexpr
|
|
use-xdg-base-directories = true;
|
|
|
|
# use flakes
|
|
experimental-features = [
|
|
"nix-command"
|
|
"flakes"
|
|
];
|
|
substituters = [
|
|
"https://nix-community.cachix.org"
|
|
"https://ghostty.cachix.org"
|
|
"https://rayandrew.cachix.org"
|
|
"https://devenv.cachix.org"
|
|
"https://yazi.cachix.org"
|
|
"https://rslib.cachix.org"
|
|
];
|
|
# allow building and pushing of laptop config from desktop
|
|
trusted-users = [ user ];
|
|
trusted-public-keys = [
|
|
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
|
|
"ghostty.cachix.org-1:QB389yTa6gTyneehvqG58y0WnHjQOqgnA+wBnpWWxns="
|
|
"rayandrew.cachix.org-1:kJnvdWgUyErPGaQWgh/yyu91szgRYD+V/WQ4Dbc4n9M="
|
|
"devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw="
|
|
"yazi.cachix.org-1:Dcdz63NZKfvUCbDGngQDAZq6kOroIrFoyO064uvLh8k="
|
|
"rslib.cachix.org-1:8OHneG2sLeTDlsZ4AZyNh8zx2zAwoiZUKVPnl21B+58="
|
|
];
|
|
};
|
|
# // lib.optionalAttrs (config.nix.package.pname == "lix") {
|
|
# repl-overlays = [ ./repl-overlays.nix ];
|
|
# };
|
|
};
|
|
|
|
nixpkgs.hostPlatform = system;
|
|
# add nixos-option workaround for flakes
|
|
# https://github.com/NixOS/nixpkgs/issues/97855#issuecomment-1075818028
|
|
nixpkgs.overlays = [
|
|
(_: prev: {
|
|
nixos-option =
|
|
let
|
|
flake-compat = prev.fetchFromGitHub {
|
|
owner = "edolstra";
|
|
repo = "flake-compat";
|
|
rev = "12c64ca55c1014cdc1b16ed5a804aa8576601ff2";
|
|
hash = "sha256-hY8g6H2KFL8ownSiFeMOjwPC8P0ueXpCVEbxgda3pko=";
|
|
};
|
|
prefix = ''(import ${flake-compat} { src = ${dots}; }).defaultNix.nixosConfigurations.${host}'';
|
|
in
|
|
prev.runCommandNoCC "nixos-option" { buildInputs = [ prev.makeWrapper ]; } ''
|
|
makeWrapper ${lib.getExe prev.nixos-option} $out/bin/nixos-option \
|
|
--add-flags --config_expr \
|
|
--add-flags "\"${prefix}.config\"" \
|
|
--add-flags --options_expr \
|
|
--add-flags "\"${prefix}.options\""
|
|
'';
|
|
})
|
|
];
|
|
}
|