about summary refs log tree commit diff
path: root/lib
diff options
context:
space:
mode:
authorsefidel <contact@sefidel.net>2022-09-09 17:49:03 +0900
committersefidel <contact@sefidel.net>2022-09-09 21:32:31 +0900
commit9e6145c031b47fc37398b80dec1b4dfc0cfb5183 (patch)
treef27e3c50a0c25223931e7057616e456432007de9 /lib
parent9e311725d4f6c68284e3999c01735ebe3665a14d (diff)
downloadnixrc-9e6145c031b47fc37398b80dec1b4dfc0cfb5183.tar.gz
nixrc-9e6145c031b47fc37398b80dec1b4dfc0cfb5183.zip
milestone: darwin!
feat(darwin/kompakt)!: support darwin

chore: reformat

feat(home/o32): manage neovim

feat(home/development): fix haskell lsp version mismatch

feat(darwin/*): stabilise
Diffstat (limited to 'lib')
-rw-r--r--lib/default.nix1
-rw-r--r--lib/mk_darwin.nix23
-rw-r--r--lib/mk_home.nix28
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 {