diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/default.nix | 1 | ||||
-rw-r--r-- | lib/mk_darwin.nix | 23 | ||||
-rw-r--r-- | lib/mk_home.nix | 28 |
3 files changed, 50 insertions, 2 deletions
diff --git a/lib/default.nix b/lib/default.nix index b75be10..704a15e 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -3,6 +3,7 @@ inputs: { mkSystem = import ./mk_system.nix inputs; mkHome = import ./mk_home.nix inputs; + mkDarwin = import ./mk_darwin.nix inputs; nixosConfigurationsAsPackages = import ./nixos_configurations_as_packages.nix inputs; homeConfigurationsAsPackages = import ./home_configurations_as_packages.nix inputs; } diff --git a/lib/mk_darwin.nix b/lib/mk_darwin.nix new file mode 100644 index 0000000..1e81a3c --- /dev/null +++ b/lib/mk_darwin.nix @@ -0,0 +1,23 @@ +{ self, darwin, ... } @ args: + +{ name, nixpkgs, system ? "aarch64-darwin", overlays ? null, extraModules ? null }: +darwin.lib.darwinSystem ( + let + configFolder = "${self}/darwin"; + entryPoint = "${configFolder}/${name}/configuration.nix"; + in + { + system = system; + inputs = { inherit darwin nixpkgs; }; + + modules = [ + { + _module.args = args; + networking.hostName = name; + } + entryPoint + ../nixos/modules/nix.nix + ] ++ nixpkgs.lib.optional (overlays != null) { nixpkgs.overlays = overlays; } + ++ nixpkgs.lib.optionals (extraModules != null) extraModules; + } +) diff --git a/lib/mk_home.nix b/lib/mk_home.nix index b2f87dc..a1466ba 100644 --- a/lib/mk_home.nix +++ b/lib/mk_home.nix @@ -3,7 +3,7 @@ { username, hostname, pkgs, version, extraModules ? null }: let entrypoint = "${self}/home/${hostname}/${username}.nix"; - defaultModule = { lib, ... }: { + defaultModule = { lib, config, ... }: { _module.args.inputs = self.inputs; _module.args.self = self; @@ -15,9 +15,33 @@ let home = { inherit username; - homeDirectory = "/home/${username}"; + homeDirectory = if pkgs.stdenv.isDarwin then "/Users/${username}" else "/home/${username}"; stateVersion = version; }; + + # Make applications pop up in finder/spotlight + home.activation = lib.mkIf pkgs.stdenv.isDarwin { + copyApplications = + let + apps = pkgs.buildEnv { + name = "home-manager-applications"; + paths = config.home.packages; + pathsToLink = "/Applications"; + }; + in + lib.hm.dag.entryAfter [ "writeBoundary" ] '' + baseDir="$HOME/Applications/Home Manager Apps" + if [ -d "$baseDir" ]; then + rm -rf "$baseDir" + fi + mkdir -p "$baseDir" + for appFile in ${apps}/Applications/*; do + target="$baseDir/$(basename "$appFile")" + $DRY_RUN_CMD cp ''${VERBOSE_ARG:+-v} -fHRL "$appFile" "$baseDir" + $DRY_RUN_CMD chmod ''${VERBOSE_ARG:+-v} -R +w "$target" + done + ''; + }; }; in home-manager.lib.homeManagerConfiguration { |