refactor pkgs, allow NixOS HM module to be used
This commit is contained in:
parent
d86b83c319
commit
6a329dab38
13
README.md
13
README.md
|
@ -1,12 +1,9 @@
|
||||||
# My Nix config
|
# My Nix config
|
||||||
|
|
||||||
To install, simply run `nixos-rebuild switch --flake .` and
|
To install, simply run `nixos-rebuild switch --flake .` and
|
||||||
`home-manager switch --flake .`.
|
`home-manager switch --flake .`... just kidding, this config relies on a
|
||||||
|
bunch of secrets that I'm too lazy to make defaults for (such as initial
|
||||||
The reason I don't use the NixOS home-manager module is is because I
|
root password for impermanence), so you won't be able to run it as-is.
|
||||||
want to be able to iterate home config quickly, and `nixos-rebuild`'ing
|
|
||||||
the entire system for every little change is pretty annoying (not to
|
|
||||||
mention the necessity of `sudo`). I'll probably merge them later,
|
|
||||||
especially after [Tvix](https://tvl.fyi/blog/rewriting-nix) becomes
|
|
||||||
feature-complete.
|
|
||||||
|
|
||||||
|
Home-manager config and modules are in `./home`, NixOS config and
|
||||||
|
modules are in `./system`.
|
||||||
|
|
|
@ -152,11 +152,11 @@
|
||||||
"utils": "utils"
|
"utils": "utils"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1684962389,
|
"lastModified": 1684964237,
|
||||||
"narHash": "sha256-pGAbDgIusNLVUFF5BcfI8ZPQGuQvMmlINOJUztHZrsg=",
|
"narHash": "sha256-dDS+GhdZN2MAa2FJKFGM2gpgAXhx+xoMkpVsRx9qpDE=",
|
||||||
"owner": "simple-nixos-mailserver",
|
"owner": "simple-nixos-mailserver",
|
||||||
"repo": "nixos-mailserver",
|
"repo": "nixos-mailserver",
|
||||||
"rev": "fd605a419bcad2513844ccee0fc6f7760cdd657e",
|
"rev": "1bcfcf786bc289ca1bd2c9d29d6f02d9141b1da3",
|
||||||
"type": "gitlab"
|
"type": "gitlab"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
142
flake.nix
142
flake.nix
|
@ -36,56 +36,35 @@
|
||||||
if builtins.pathExists ./private.nix then (import ./private.nix)
|
if builtins.pathExists ./private.nix then (import ./private.nix)
|
||||||
else if builtins.pathExists ./private/default.nix then (import ./private)
|
else if builtins.pathExists ./private/default.nix then (import ./private)
|
||||||
else { };
|
else { };
|
||||||
|
# if x has key s, get it. Otherwise return def
|
||||||
getOr = def: s: x: with builtins; if hasAttr s x then getAttr s x else def;
|
getOr = def: s: x: with builtins; if hasAttr s x then getAttr s x else def;
|
||||||
|
# All private config for hostname
|
||||||
getPriv = hostname: getOr { } hostname priv;
|
getPriv = hostname: getOr { } hostname priv;
|
||||||
|
# Private NixOS config for hostname
|
||||||
getPrivSys = hostname: getOr { } "system" (getPriv hostname);
|
getPrivSys = hostname: getOr { } "system" (getPriv hostname);
|
||||||
|
# Private home-manager config for hostname and username
|
||||||
getPrivUser = hostname: user: getOr { } user (getPriv hostname);
|
getPrivUser = hostname: user: getOr { } user (getPriv hostname);
|
||||||
|
# extended lib
|
||||||
lib = nixpkgs.lib // {
|
lib = nixpkgs.lib // {
|
||||||
quoteListenAddr = addr:
|
quoteListenAddr = addr:
|
||||||
if nixpkgs.lib.hasInfix ":" addr then "[${addr}]" else addr;
|
if nixpkgs.lib.hasInfix ":" addr then "[${addr}]" else addr;
|
||||||
};
|
};
|
||||||
config = {
|
# can't use callPackage here, idk why; use import instead
|
||||||
nixmsi = rec {
|
overlay = self: super: import ./pkgs {
|
||||||
system = "x86_64-linux";
|
pkgs = super;
|
||||||
modules = [
|
lib = super.lib;
|
||||||
nix-gaming.nixosModules.pipewireLowLatency
|
nur = import nur {
|
||||||
./system/hardware/msi_delta_15.nix
|
pkgs = super;
|
||||||
./system/hosts/nixmsi.nix
|
nurpkgs = super;
|
||||||
];
|
|
||||||
home.user = {
|
|
||||||
pkgs = import nixpkgs {
|
|
||||||
inherit system;
|
|
||||||
binaryCachePublicKeys = [
|
|
||||||
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
|
|
||||||
# "nixpkgs-wayland.cachix.org-1:3lwxaILxMRkVhehr5StQprHdEo4IrE8sRho9R9HOLYA="
|
|
||||||
];
|
|
||||||
binaryCaches = [
|
|
||||||
"https://cache.nixos.org"
|
|
||||||
# "https://nixpkgs-wayland.cachix.org"
|
|
||||||
];
|
|
||||||
overlays = [
|
|
||||||
(self: super: import ./home/pkgs {
|
|
||||||
# can't use callPackage here, idk why
|
|
||||||
pkgs = super;
|
|
||||||
lib = super.lib;
|
|
||||||
nur = import nur {
|
|
||||||
pkgs = super;
|
|
||||||
nurpkgs = super;
|
|
||||||
};
|
|
||||||
nix-gaming = nix-gaming.packages.${system};
|
|
||||||
})
|
|
||||||
];
|
|
||||||
};
|
|
||||||
extraSpecialArgs = {
|
|
||||||
notlua = notlua.lib.${system};
|
|
||||||
# pkgs-wayland = nixpkgs-wayland.packages.${system};
|
|
||||||
};
|
|
||||||
modules = [
|
|
||||||
nur.nixosModules.nur
|
|
||||||
./home/hosts/nixmsi.nix
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
nix-gaming = nix-gaming.packages.${super.system};
|
||||||
|
};
|
||||||
|
# I override some settings down the line, but overlays always stay the same
|
||||||
|
mkPkgs = config: import nixpkgs (config // {
|
||||||
|
overlays = (if config?overlays then config.overlays else [ ]) ++ [ overlay ];
|
||||||
|
});
|
||||||
|
# this is actual config, it gets processed later
|
||||||
|
config = {
|
||||||
nixserver = {
|
nixserver = {
|
||||||
modules = [
|
modules = [
|
||||||
nixos-mailserver.nixosModules.default
|
nixos-mailserver.nixosModules.default
|
||||||
|
@ -100,11 +79,55 @@
|
||||||
./system/hosts/router
|
./system/hosts/router
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
nixmsi = rec {
|
||||||
|
system = "x86_64-linux";
|
||||||
|
nixpkgs.config.allowUnfreePredicate = pkg: (lib.getName pkg) == "steam-original";
|
||||||
|
modules = [
|
||||||
|
nix-gaming.nixosModules.pipewireLowLatency
|
||||||
|
./system/hardware/msi_delta_15.nix
|
||||||
|
./system/hosts/nixmsi.nix
|
||||||
|
];
|
||||||
|
home.common.pkgs = mkPkgs {
|
||||||
|
inherit system;
|
||||||
|
config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
|
||||||
|
"steam-run"
|
||||||
|
"steam"
|
||||||
|
"steam-original"
|
||||||
|
"steam-runtime"
|
||||||
|
"steamcmd"
|
||||||
|
"osu-lazer-bin"
|
||||||
|
];
|
||||||
|
binaryCachePublicKeys = [
|
||||||
|
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
|
||||||
|
# "nixpkgs-wayland.cachix.org-1:3lwxaILxMRkVhehr5StQprHdEo4IrE8sRho9R9HOLYA="
|
||||||
|
];
|
||||||
|
binaryCaches = [
|
||||||
|
"https://cache.nixos.org"
|
||||||
|
# "https://nixpkgs-wayland.cachix.org"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
home.common.extraSpecialArgs = {
|
||||||
|
notlua = notlua.lib.${system};
|
||||||
|
};
|
||||||
|
home.user = [
|
||||||
|
nur.nixosModules.nur
|
||||||
|
./home/hosts/nixmsi.nix
|
||||||
|
];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
nixosConfigurations = builtins.mapAttrs (hostname: args @ { system ? "x86_64-linux", modules, ... }:
|
overlays.default = overlay;
|
||||||
|
packages = lib.genAttrs [
|
||||||
|
"x86_64-linux"
|
||||||
|
"aarch64-linux"
|
||||||
|
] (system: let self = overlay self (import nixpkgs { inherit system; }); in self );
|
||||||
|
# this is the system config part
|
||||||
|
nixosConfigurations = builtins.mapAttrs (hostname: args @ { system ? "x86_64-linux", modules, nixpkgs ? {}, home ? {}, ... }:
|
||||||
lib.nixosSystem ({
|
lib.nixosSystem ({
|
||||||
inherit system;
|
inherit system;
|
||||||
|
pkgs = mkPkgs ({
|
||||||
|
inherit system;
|
||||||
|
} // nixpkgs);
|
||||||
modules = modules ++ [
|
modules = modules ++ [
|
||||||
{ networking.hostName = hostname; }
|
{ networking.hostName = hostname; }
|
||||||
./system/modules/vfio.nix
|
./system/modules/vfio.nix
|
||||||
|
@ -128,27 +151,48 @@
|
||||||
(lib.filterAttrs (_: v: builtins.pathExists "${v}/default.nix") inputs);
|
(lib.filterAttrs (_: v: builtins.pathExists "${v}/default.nix") inputs);
|
||||||
nix.nixPath = [ "/etc/nix/inputs" ];
|
nix.nixPath = [ "/etc/nix/inputs" ];
|
||||||
}
|
}
|
||||||
];
|
] ++ (lib.optionals (home != {} && (!(home?common) || !(home.common?pkgs))) [
|
||||||
|
# only use NixOS HM module if same nixpkgs as system nixpkgs is used for user
|
||||||
|
# why? because it seems that HM lacks the option to override pkgs, only change nixpkgs.* settings
|
||||||
|
home-manager.nixosModules.home-manager
|
||||||
|
{
|
||||||
|
home-manager = builtins.removeAttrs (getOr { } "common" home) [ "nixpkgs" ];
|
||||||
|
}
|
||||||
|
{
|
||||||
|
home-manager.useGlobalPkgs = true;
|
||||||
|
home-manager.useUserPackages = true;
|
||||||
|
home-manager.users = builtins.mapAttrs (k: v: {
|
||||||
|
imports = v ++ [ {
|
||||||
|
nixpkgs = getOr { } "nixpkgs" (getOr { } "common" home);
|
||||||
|
} ];
|
||||||
|
}) (builtins.removeAttrs home [ "common" ]);
|
||||||
|
}
|
||||||
|
]);
|
||||||
specialArgs = {
|
specialArgs = {
|
||||||
inherit lib nixpkgs;
|
inherit lib nixpkgs;
|
||||||
hardware = nixos-hardware.nixosModules;
|
hardware = nixos-hardware.nixosModules;
|
||||||
};
|
};
|
||||||
} // (builtins.removeAttrs args [ "home" "modules" ])))
|
} // (builtins.removeAttrs args [ "home" "modules" "nixpkgs" ])))
|
||||||
config;
|
config;
|
||||||
|
# for each hostname, for each user, generate an attribute "${user}@${hostname}"
|
||||||
homeConfigurations =
|
homeConfigurations =
|
||||||
builtins.foldl'
|
builtins.foldl'
|
||||||
(a: b: a // b)
|
(a: b: a // b)
|
||||||
{ }
|
{ }
|
||||||
(builtins.concatLists
|
(builtins.concatLists
|
||||||
(lib.mapAttrsToList
|
(lib.mapAttrsToList
|
||||||
(hostname: config:
|
(hostname: sysConfig:
|
||||||
|
let common = builtins.removeAttrs (getOr { } "common" sysConfig.home) [ "nixpkgs" ]; in
|
||||||
lib.mapAttrsToList
|
lib.mapAttrsToList
|
||||||
(user: config@{ modules, ... }: {
|
# this is where actual config takes place
|
||||||
"${user}@${hostname}" = home-manager.lib.homeManagerConfiguration (config // {
|
(user: homeConfig: {
|
||||||
modules = config.modules ++ [ (getPrivUser hostname user) ];
|
"${user}@${hostname}" = home-manager.lib.homeManagerConfiguration (common // {
|
||||||
|
modules = homeConfig ++ [
|
||||||
|
(getPrivUser hostname user)
|
||||||
|
];
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
(getOr { } "home" config))
|
(builtins.removeAttrs (getOr { } "home" sysConfig) [ "common" ]))
|
||||||
config));
|
config));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,14 +29,6 @@
|
||||||
enable = true;
|
enable = true;
|
||||||
};
|
};
|
||||||
services.kdeconnect.enable = true;
|
services.kdeconnect.enable = true;
|
||||||
nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
|
|
||||||
"steam-run"
|
|
||||||
"steam"
|
|
||||||
"steam-original"
|
|
||||||
"steam-runtime"
|
|
||||||
"steamcmd"
|
|
||||||
"osu-lazer-bin"
|
|
||||||
];
|
|
||||||
home.sessionVariables = {
|
home.sessionVariables = {
|
||||||
STEAM_EXTRA_COMPAT_TOOLS_PATHS = "${pkgs.proton-ge}";
|
STEAM_EXTRA_COMPAT_TOOLS_PATHS = "${pkgs.proton-ge}";
|
||||||
CARGO_PROFILE_DEV_INCREMENTAL = "true";
|
CARGO_PROFILE_DEV_INCREMENTAL = "true";
|
||||||
|
|
0
system/pkgs/Cargo.lock → pkgs/Cargo.lock
generated
0
system/pkgs/Cargo.lock → pkgs/Cargo.lock
generated
|
@ -5,7 +5,7 @@
|
||||||
, ... }:
|
, ... }:
|
||||||
let
|
let
|
||||||
inherit (pkgs) callPackage;
|
inherit (pkgs) callPackage;
|
||||||
sources = import ../_sources/generated.nix {
|
sources = import ./_sources/generated.nix {
|
||||||
inherit (pkgs) fetchgit fetchurl fetchFromGitHub dockerTools;
|
inherit (pkgs) fetchgit fetchurl fetchFromGitHub dockerTools;
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
|
@ -30,6 +30,8 @@ in
|
||||||
fetchSubmodules = true;
|
fetchSubmodules = true;
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
maubot = callPackage ./maubot.nix { };
|
||||||
|
pineapplebot = callPackage ./pineapplebot.nix { };
|
||||||
proton-ge = pkgs.stdenvNoCC.mkDerivation {
|
proton-ge = pkgs.stdenvNoCC.mkDerivation {
|
||||||
inherit (sources.proton-ge) pname version src;
|
inherit (sources.proton-ge) pname version src;
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
|
@ -38,6 +40,7 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
rofi-steam-game-list = callPackage ./rofi-steam-game-list { };
|
rofi-steam-game-list = callPackage ./rofi-steam-game-list { };
|
||||||
|
system76-scheduler = callPackage ./system76-scheduler.nix { };
|
||||||
techmino = callPackage ./techmino { };
|
techmino = callPackage ./techmino { };
|
||||||
|
|
||||||
firefox-addons = lib.recurseIntoAttrs (callPackage ./firefox-addons { inherit nur sources; });
|
firefox-addons = lib.recurseIntoAttrs (callPackage ./firefox-addons { inherit nur sources; });
|
2
postpush.sh
Executable file
2
postpush.sh
Executable file
|
@ -0,0 +1,2 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
mv .git .git.bak
|
2
push.sh
2
push.sh
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
git push
|
git push
|
||||||
git push github master
|
git push github master
|
||||||
mv .git .git.bak
|
./postpush.sh
|
||||||
|
|
|
@ -93,7 +93,6 @@ in {
|
||||||
# zen619.configuration.boot.kernelPackages = zenKernelPackages "6.1.9" "0fsmcjsawxr32fxhpp6sgwfwwj8kqymy0rc6vh4qli42fqmwdjgv";
|
# zen619.configuration.boot.kernelPackages = zenKernelPackages "6.1.9" "0fsmcjsawxr32fxhpp6sgwfwwj8kqymy0rc6vh4qli42fqmwdjgv";
|
||||||
# };
|
# };
|
||||||
|
|
||||||
nixpkgs.config.allowUnfreePredicate = pkg: (lib.getName pkg) == "steam-original";
|
|
||||||
hardware = {
|
hardware = {
|
||||||
steam-hardware.enable = true;
|
steam-hardware.enable = true;
|
||||||
opengl.driSupport32Bit = true;
|
opengl.driSupport32Bit = true;
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
{ pkgs
|
|
||||||
, lib
|
|
||||||
, ... }:
|
|
||||||
|
|
||||||
let
|
|
||||||
inherit (pkgs) callPackage;
|
|
||||||
in {
|
|
||||||
system76-scheduler = callPackage ./system76-scheduler.nix { };
|
|
||||||
maubot = callPackage ./maubot.nix { };
|
|
||||||
pineapplebot = callPackage ./pineapplebot.nix { };
|
|
||||||
inherit lib;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
// (lib.optionalAttrs (pkgs.system == "...") {
|
|
||||||
fdroidserver = pkgs.fdroidserver.overridePythonAttrs (oldAttrs: {
|
|
||||||
# remove apksigner, since official Android SDK is unavailable on arm64
|
|
||||||
makeWrapperArgs = [ ];
|
|
||||||
});
|
|
||||||
})
|
|
||||||
*/
|
|
16
update.sh
16
update.sh
|
@ -1,11 +1,15 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
cp ~/.config/nixpkgs/overlays.nix ./overlays.nix || echo "probably no overlays exist"
|
cp ~/.config/nixpkgs/overlays.nix ./overlays.nix || (mkdir -p ~/.config/nixpkgs && cp ./overlays.nix ~/.config/nixpkgs)
|
||||||
nix flake update
|
nix flake update
|
||||||
nvfetcher \
|
nvfetcher \
|
||||||
-o ./home/_sources \
|
-o ./pkgs/_sources \
|
||||||
-c ./home/nvfetcher.toml || echo "failed to update nvfetcher sources"
|
-c ./pkgs/nvfetcher.toml || echo "failed to update nvfetcher sources"
|
||||||
mozilla-addons-to-nix \
|
mozilla-addons-to-nix \
|
||||||
./home/pkgs/firefox-addons/addons.json \
|
./pkgs/firefox-addons/addons.json \
|
||||||
./home/pkgs/firefox-addons/generated.nix || echo "failed to update firefox addons"
|
./pkgs/firefox-addons/generated.nix || echo "failed to update firefox addons"
|
||||||
s nixos-rebuild switch --flake . || sudo nixos-rebuild switch --flake .
|
if [ -z ${SUDO_ASKPASS+x} ]; then
|
||||||
|
sudo nixos-rebuild switch --flake .
|
||||||
|
else
|
||||||
|
sudo -A nixos-rebuild switch --flake .
|
||||||
|
fi
|
||||||
home-manager switch --flake .
|
home-manager switch --flake .
|
||||||
|
|
Loading…
Reference in a new issue