diff --git a/flake.lock b/flake.lock index ad2837f..e46cd7a 100644 --- a/flake.lock +++ b/flake.lock @@ -88,6 +88,21 @@ "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": { "inputs": { "nixpkgs": [ @@ -177,6 +192,7 @@ "agenix": "agenix", "darwin": "darwin", "ffmac": "ffmac", + "flake-utils": "flake-utils", "home-manager": "home-manager", "nixunstable": "nixunstable", "nurpkgs": "nurpkgs", @@ -203,7 +219,7 @@ "wsl": { "inputs": { "flake-compat": "flake-compat", - "flake-utils": "flake-utils", + "flake-utils": "flake-utils_2", "nixpkgs": [ "nixunstable" ] diff --git a/flake.nix b/flake.nix index 4c8d7d3..ce22878 100644 --- a/flake.nix +++ b/flake.nix @@ -8,6 +8,7 @@ stable.url = "github:nixos/nixpkgs/nixos-22.05"; nixunstable.url = "github:nixos/nixpkgs/nixos-unstable"; agenix.url = "github:ryantm/agenix"; + flake-utils.url = "github:numtide/flake-utils"; home-manager = { url = "github:nix-community/home-manager/release-22.05"; inputs.nixpkgs.follows = "stable"; @@ -24,7 +25,7 @@ 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 local_overlay = import ./overlays; overlays = [ @@ -108,17 +109,11 @@ }; }; - #"x86_64-linux" = inputs.self.nixosConfigurations.iso.config.system.build.isoImage; - #"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; - }; + defaultPackage = flake-utils.lib.eachDefaultSystemMap (system: inputs.self.homeConfigurations.gui."${system}".activationPackage); homeConfigurations = ( import ./home { - inherit nixunstable agenix home-manager overlays; + inherit nixunstable agenix home-manager overlays flake-utils; nixpkgs = nixunstable; } ); diff --git a/garnix.yaml b/garnix.yaml index 1c2f208..3887417 100644 --- a/garnix.yaml +++ b/garnix.yaml @@ -6,6 +6,6 @@ builds: - defaultPackage.x86_64-linux - defaultPackage.aarch64-linux - defaultPackage.x86_64-darwin - - darwinConfigurations.C02G48H8MD6R + - defaultPackage.aarch64-darwin exclude: - nixosConfigurations.linode # Requires decrypted files diff --git a/home/default.nix b/home/default.nix index 8c28d1e..06417d3 100644 --- a/home/default.nix +++ b/home/default.nix @@ -2,27 +2,31 @@ nixpkgs, overlays, home-manager, - username ? builtins.getEnv "USER", + flake-utils, ... }: 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 ( nixpkgs.lib.hasSuffix "-darwin" system ) then "/Users/${username}" else "/home/${username}" ); mkhome = { system, gui, - gnome + gnome, + username }: let - homeDirectory = home system; + homeDirectory = home system username; configDir = "${homeDirectory}/.config"; pkgs = import nixpkgs { - inherit overlays; + inherit overlays system; config.allowUnfree = true; 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; gnome = true; + username = user system; }; - - cli = { + cli = mkhome { + inherit system; gui = 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); -} +}) diff --git a/overlays/hms.sh b/overlays/hms.sh index 5ecffa2..d34fcf2 100644 --- a/overlays/hms.sh +++ b/overlays/hms.sh @@ -6,25 +6,25 @@ arch="$(uname -m)" if [ "$(uname -s)" == "Darwin" ]; then # On macOS src="${HOME}/.config/nix/" - target="${arch}-darwin" + flavor="gui" elif [ x"${WSL_DISTRO_NAME}" != "x" ]; then src=/etc/nixos - target="wsl" + flavor="cli" else - # On Linux/WSL2 systems + # On Linux systems if [ -z "${DISPLAY}" ]; then - target="${arch}-nogui" + flavor="cli" else - target="${arch}-gui" + flavor="gdm" fi src=/etc/nixos fi # Build and switch -echo "Building ${target}" +echo "Building ${flavor}.${arch}" dest=$(mktemp -d) pushd "${dest}" > /dev/null -nix build --impure "${src}#homeConfigurations.${target}.activationPackage" +nix build "${src}#homeConfigurations.${flavor}.${arch}.activationPackage" ./result/activate popd > /dev/null rm -r "${dest}"