Make everything purer

This commit is contained in:
Greg Hellings
2023-03-06 23:31:58 -06:00
parent c983a3de2c
commit 02c88a1b0d
5 changed files with 52 additions and 43 deletions
Generated
+17 -1
View File
@@ -88,6 +88,21 @@
"type": "github" "type": "github"
} }
}, },
"flake-utils_2": {
"locked": {
"lastModified": 1676283394,
"narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"home-manager": { "home-manager": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@@ -177,6 +192,7 @@
"agenix": "agenix", "agenix": "agenix",
"darwin": "darwin", "darwin": "darwin",
"ffmac": "ffmac", "ffmac": "ffmac",
"flake-utils": "flake-utils",
"home-manager": "home-manager", "home-manager": "home-manager",
"nixunstable": "nixunstable", "nixunstable": "nixunstable",
"nurpkgs": "nurpkgs", "nurpkgs": "nurpkgs",
@@ -203,7 +219,7 @@
"wsl": { "wsl": {
"inputs": { "inputs": {
"flake-compat": "flake-compat", "flake-compat": "flake-compat",
"flake-utils": "flake-utils", "flake-utils": "flake-utils_2",
"nixpkgs": [ "nixpkgs": [
"nixunstable" "nixunstable"
] ]
+4 -9
View File
@@ -8,6 +8,7 @@
stable.url = "github:nixos/nixpkgs/nixos-22.05"; stable.url = "github:nixos/nixpkgs/nixos-22.05";
nixunstable.url = "github:nixos/nixpkgs/nixos-unstable"; nixunstable.url = "github:nixos/nixpkgs/nixos-unstable";
agenix.url = "github:ryantm/agenix"; agenix.url = "github:ryantm/agenix";
flake-utils.url = "github:numtide/flake-utils";
home-manager = { home-manager = {
url = "github:nix-community/home-manager/release-22.05"; url = "github:nix-community/home-manager/release-22.05";
inputs.nixpkgs.follows = "stable"; inputs.nixpkgs.follows = "stable";
@@ -24,7 +25,7 @@
ffmac.url = "github:bandithedoge/nixpkgs-firefox-darwin"; ffmac.url = "github:bandithedoge/nixpkgs-firefox-darwin";
}; };
outputs = {stable, nixunstable, agenix, home-manager, nurpkgs, self, wsl, ...}@inputs: outputs = {stable, nixunstable, agenix, home-manager, nurpkgs, self, wsl, flake-utils, ...}@inputs:
let let
local_overlay = import ./overlays; local_overlay = import ./overlays;
overlays = [ overlays = [
@@ -108,17 +109,11 @@
}; };
}; };
#"x86_64-linux" = inputs.self.nixosConfigurations.iso.config.system.build.isoImage; defaultPackage = flake-utils.lib.eachDefaultSystemMap (system: inputs.self.homeConfigurations.gui."${system}".activationPackage);
#"x86_64-darwin" = inputs.self.darwinConfigurations.C02G48H8MD6R.system;
defaultPackage = {
"x86_64-linux" = inputs.self.homeConfigurations."x86_64-gui".activationPackage;
"aarch64-linux" = inputs.self.homeConfigurations."aarch64-gui".activationPackage;
"x86_64-darwin" = inputs.self.homeConfigurations."x86_64-darwin".activationPackage;
};
homeConfigurations = ( homeConfigurations = (
import ./home { import ./home {
inherit nixunstable agenix home-manager overlays; inherit nixunstable agenix home-manager overlays flake-utils;
nixpkgs = nixunstable; nixpkgs = nixunstable;
} }
); );
+1 -1
View File
@@ -6,6 +6,6 @@ builds:
- defaultPackage.x86_64-linux - defaultPackage.x86_64-linux
- defaultPackage.aarch64-linux - defaultPackage.aarch64-linux
- defaultPackage.x86_64-darwin - defaultPackage.x86_64-darwin
- darwinConfigurations.C02G48H8MD6R - defaultPackage.aarch64-darwin
exclude: exclude:
- nixosConfigurations.linode # Requires decrypted files - nixosConfigurations.linode # Requires decrypted files
+23 -25
View File
@@ -2,27 +2,31 @@
nixpkgs, nixpkgs,
overlays, overlays,
home-manager, home-manager,
username ? builtins.getEnv "USER", flake-utils,
... ...
}: }:
let let
home = system: # I'm "greg" everywhere except Darwin where I'm "gregory.hellings"
user = system:
( if ( nixpkgs.lib.hasSuffix "-darwin" system ) then "gregory.hellings" else "greg" );
home = system: username:
if username == "root" then "/root" else if username == "root" then "/root" else
( if ( nixpkgs.lib.hasSuffix "-darwin" system ) then "/Users/${username}" else "/home/${username}" ); ( if ( nixpkgs.lib.hasSuffix "-darwin" system ) then "/Users/${username}" else "/home/${username}" );
mkhome = { mkhome = {
system, system,
gui, gui,
gnome gnome,
username
}: }:
let let
homeDirectory = home system; homeDirectory = home system username;
configDir = "${homeDirectory}/.config"; configDir = "${homeDirectory}/.config";
pkgs = import nixpkgs { pkgs = import nixpkgs {
inherit overlays; inherit overlays system;
config.allowUnfree = true; config.allowUnfree = true;
config.xdg.configHome = configDir; config.xdg.configHome = configDir;
}; };
@@ -36,29 +40,23 @@ let
}; };
}; };
gdm = { in flake-utils.lib.eachDefaultSystem (system: {
gui = mkhome {
inherit system;
gui = true;
gnome = false;
username = user system;
};
gdm = mkhome {
inherit system;
gui = true; gui = true;
gnome = true; gnome = true;
username = user system;
}; };
cli = mkhome {
cli = { inherit system;
gui = false; gui = false;
gnome = false; gnome = false;
username = user system;
}; };
})
gui = {
gui = true;
gnome = false;
};
arm = { system = "aarch64-linux"; };
x86 = { system = "x86_64-linux"; };
darwin = { system = "x86_64-darwin"; };
in {
"wsl" = mkhome (gui // arm);
"aarch64-gui" = mkhome (gdm // arm);
"aarch64-nogui" = mkhome (cli // arm);
"x86_64-gui" = mkhome (gdm // x86);
"x86_64-nogui" = mkhome (cli // x86);
"x86_64-darwin" = mkhome (gui // darwin);
}
+7 -7
View File
@@ -6,25 +6,25 @@ arch="$(uname -m)"
if [ "$(uname -s)" == "Darwin" ]; then if [ "$(uname -s)" == "Darwin" ]; then
# On macOS # On macOS
src="${HOME}/.config/nix/" src="${HOME}/.config/nix/"
target="${arch}-darwin" flavor="gui"
elif [ x"${WSL_DISTRO_NAME}" != "x" ]; then elif [ x"${WSL_DISTRO_NAME}" != "x" ]; then
src=/etc/nixos src=/etc/nixos
target="wsl" flavor="cli"
else else
# On Linux/WSL2 systems # On Linux systems
if [ -z "${DISPLAY}" ]; then if [ -z "${DISPLAY}" ]; then
target="${arch}-nogui" flavor="cli"
else else
target="${arch}-gui" flavor="gdm"
fi fi
src=/etc/nixos src=/etc/nixos
fi fi
# Build and switch # Build and switch
echo "Building ${target}" echo "Building ${flavor}.${arch}"
dest=$(mktemp -d) dest=$(mktemp -d)
pushd "${dest}" > /dev/null pushd "${dest}" > /dev/null
nix build --impure "${src}#homeConfigurations.${target}.activationPackage" nix build "${src}#homeConfigurations.${flavor}.${arch}.activationPackage"
./result/activate ./result/activate
popd > /dev/null popd > /dev/null
rm -r "${dest}" rm -r "${dest}"