Be more specific on Darwin

This commit is contained in:
greg-compass
2022-09-09 11:54:18 -05:00
parent 5912ca4bcc
commit d0a233fed7
2 changed files with 35 additions and 24 deletions
+25 -17
View File
@@ -1,25 +1,32 @@
{ nixpkgs, nurpkgs, home-manager, username ? builtins.getEnv "USER", ... }:
let
homeDirectory = if username == "root" then "/root" else "/home/${username}";
configDir = "${homeDirectory}/.config";
pkgs = import nixpkgs {
config.allowUnfree = true;
config.xdg.configHome = configDir;
overlays = [
nurpkgs.overlay
(import ../overlays)
];
};
nur = import nurpkgs {
inherit pkgs;
nur = pkgs;
};
home = system:
if username == "root" then "/root" else
( if ( nixpkgs.lib.hasSuffix "-darwin" system ) then "/Users/${username}" else "/home/${username}" );
mkhome = system: gui:
home-manager.lib.homeManagerConfiguration rec {
let
homeDirectory = home system;
configDir = "${homeDirectory}/.config";
pkgs = import nixpkgs {
config.allowUnfree = true;
config.xdg.configHome = configDir;
overlays = [
nurpkgs.overlay
(import ../overlays)
];
};
nur = import nurpkgs {
inherit pkgs;
nur = pkgs;
};
in home-manager.lib.homeManagerConfiguration rec {
inherit pkgs system username homeDirectory;
stateVersion = "22.05";
configuration = import ./home.nix username {
@@ -32,4 +39,5 @@ in {
"aarch64-nogui" = mkhome "aarch64-linux" false;
"x86_64-gui" = mkhome "x86_64-linux" true;
"x86_64-nogui" = mkhome "x86_64-linux" false;
"x86_64-darwin" = mkhome "x86_64-darwin" true;
}
+10 -7
View File
@@ -3,16 +3,19 @@
pkgs.writeShellScriptBin "hms" ''
set -eo pipefail
# Build different targets with GUI or not
if [ -z "$DISPLAY" ]; then
target="nogui"
else
target="gui"
fi
arch="$(uname -m)"
if [ "$(uname -s)" == "Darwin" ]; then
# On macOS
src="$HOME/.config/nix/"
target=gui
target="''${arch}-darwin"
else
# On Linux/WSL2 systems
if [ -z "$DISPLAY" ]; then
target="''${arch}-nogui"
else
target="''${arch}-gui"
fi
src=/etc/nixos
fi
@@ -20,7 +23,7 @@ fi
echo "Building $(uname -m)-$target"
dest=$(mktemp -d)
pushd "$dest" > /dev/null
nix build --impure "$src#homeConfigurations.$(uname -m)-$target.activationPackage"
nix build --impure "$src#homeConfigurations.$target.activationPackage"
./result/activate
popd > /dev/null
rm -r "$dest"