pass correct nixpkgs, add repl

This commit is contained in:
Dmitriy Kholkin 2024-08-04 13:40:32 +03:00
parent c3b15d99ec
commit 0c46437a19
Signed by: AtaraxiaDev
GPG Key ID: FD266B810DF48DF2
3 changed files with 43 additions and 16 deletions

View File

@ -97,9 +97,9 @@
patches = p;
};
# Get nixosSystem func from patched nixpkgs
nixosSystem = n: p: import ((nixpkgs-patched n p) + "/nixos/lib/eval-config.nix");
nixosSystem = n: import (n + "/nixos/lib/eval-config.nix");
# Make host config
mkHost = name: nixosSystem:
mkHost = name: nixosSystem: self-nixpkgs:
nixosSystem {
system = builtins.readFile (./machines + "/${name}/system");
modules = builtins.attrValues self.customModules ++ [
@ -108,7 +108,7 @@
{ nixpkgs.config.allowUnfree = true; }
inputs.sops-nix.nixosModules.sops
];
specialArgs = { inherit self; inherit inputs; secrets = ./secrets; };
specialArgs = { inherit self inputs self-nixpkgs; secrets = ./secrets; };
};
patchesPath = map (x: ./patches + "/${x}");
@ -152,8 +152,10 @@
};
flake = let
unstable = nixosSystem inputs.nixpkgs unstable-patches;
stable = nixosSystem inputs.nixpkgs-stable stable-patches;
unstable-nixpkgs = nixpkgs-patched inputs.nixpkgs unstable-patches;
stable-nixpkgs = nixpkgs-patched inputs.nixpkgs-stable stable-patches;
unstable-system = nixosSystem unstable-nixpkgs;
stable-system = nixosSystem stable-nixpkgs;
shared-patches = patchesPath [ ];
unstable-patches = shared-patches ++ patchesPath [
@ -173,15 +175,14 @@
customProfiles = builtins.listToAttrs (findModules ./profiles);
customRoles = import ./roles;
secretsDir = ./secrets;
nixpkgs-unstable-patched = nixpkgs-patched inputs.nixpkgs unstable-patches;
inherit unstable-nixpkgs;
nixosConfigurations = withSystem "x86_64-linux" ({ ... }:
{
AMD-Workstation = mkHost "AMD-Workstation" unstable;
Dell-Laptop = mkHost "Dell-Laptop" unstable;
Home-Hypervisor = mkHost "Home-Hypervisor" unstable;
NixOS-VPS = mkHost "NixOS-VPS" stable;
NixOS-VM = mkHost "NixOS-VM" unstable;
AMD-Workstation = mkHost "AMD-Workstation" unstable-system unstable-nixpkgs;
Dell-Laptop = mkHost "Dell-Laptop" unstable-system unstable-nixpkgs;
Home-Hypervisor = mkHost "Home-Hypervisor" unstable-system unstable-nixpkgs;
NixOS-VPS = mkHost "NixOS-VPS" stable-system stable-nixpkgs;
}
);

View File

@ -1,10 +1,10 @@
{ config, lib, pkgs, inputs, ... }: {
{ config, lib, pkgs, inputs, self-nixpkgs, ... }: {
nix = {
package = pkgs.lix;
nixPath = lib.mkForce [ "self=/etc/self/compat" "nixpkgs=/etc/nixpkgs" ];
nixPath = [ "self=/etc/self" "nixpkgs=/etc/nixpkgs" ];
registry.nixpkgs.flake = self-nixpkgs;
registry.self.flake = inputs.self;
registry.nixpkgs.flake = inputs.nixpkgs;
optimise.automatic = lib.mkDefault true;
@ -18,7 +18,6 @@
# Prevent Nix from fetching the registry every time
flake-registry = ${inputs.flake-registry}/flake-registry.json
'';
settings = {
auto-optimise-store = false;
require-sigs = true;
@ -32,6 +31,7 @@
"https://numtide.cachix.org"
"https://devenv.cachix.org"
"https://ezkea.cachix.org"
"https://nyx.chaotic.cx"
];
trusted-public-keys = [
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
@ -43,14 +43,30 @@
"numtide.cachix.org-1:2ps1kLBUWjxIneOy1Ik6cQjb41X0iXVXeHigGmycPPE="
"devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw="
"ezkea.cachix.org-1:ioBmUbJTZIKsHmWWXPe1FSFbeVe+afhfgqgTSNd34eI="
"nyx.chaotic.cx-1:HfnXSw4pj95iI/n17rIDy40agHj12WfF+Gqk6SonIT8="
"chaotic-nyx.cachix.org-1:HfnXSw4pj95iI/n17rIDy40agHj12WfF+Gqk6SonIT8="
];
trusted-users = [ "root" config.mainuser "deploy" "@wheel" ];
use-xdg-base-directories = true;
};
};
environment.etc.nixpkgs.source = inputs.nixpkgs;
environment.etc.nixpkgs.source = self-nixpkgs;
environment.etc.self.source = inputs.self;
environment.systemPackages = let
repl-home = "/home/${config.mainuser}/nixos-config/repl.nix";
repl = pkgs.writeShellScriptBin "repl" ''
# source /etc/set-environment
if [ -f "${repl-home}" ]; then
echo "use home flake"
nix repl "${repl-home}" "$@"
else
echo "use system flake"
nix repl "/etc/self/repl.nix" "$@"
fi
'';
in [ repl ];
persist.state.homeDirectories = [ ".local/share/nix" ];
}

10
repl.nix Normal file
View File

@ -0,0 +1,10 @@
let
flake = builtins.getFlake (toString ./.);
nixpkgs = import <nixpkgs> { };
in
{ inherit flake; }
// flake
// builtins
// nixpkgs
// nixpkgs.lib
// flake.nixosConfigurations