From 24c2d2bab7fc718a3356b1c15a8750655d9556c2 Mon Sep 17 00:00:00 2001 From: Michael Hoang Date: Thu, 8 May 2025 20:07:12 +1000 Subject: [PATCH 1/2] programs/_1password: init module --- modules/module-list.nix | 1 + modules/programs/_1password.nix | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 modules/programs/_1password.nix diff --git a/modules/module-list.nix b/modules/module-list.nix index d01bbdb..a6c2d12 100644 --- a/modules/module-list.nix +++ b/modules/module-list.nix @@ -99,6 +99,7 @@ ./services/yabai ./services/nextdns ./services/jankyborders + ./programs/_1password.nix ./programs/bash ./programs/direnv.nix ./programs/fish.nix diff --git a/modules/programs/_1password.nix b/modules/programs/_1password.nix new file mode 100644 index 0000000..982031e --- /dev/null +++ b/modules/programs/_1password.nix @@ -0,0 +1,31 @@ +{ + config, + pkgs, + lib, + ... +}: + +let + cfg = config.programs._1password; +in +{ + options = { + programs._1password = { + enable = lib.mkEnableOption "the 1Password CLI tool"; + + package = lib.mkPackageOption pkgs "1Password CLI" { + default = [ "_1password-cli" ]; + }; + }; + }; + + config = lib.mkIf cfg.enable { + # Integration with the 1Password GUI will only work if the CLI at `/usr/local/bin/op` + # Based on https://github.com/reckenrode/nixos-configs/blob/22b8357fc6ffbd0df5ce50dc417c23a807a268a2/modules/by-name/1p/1password/darwin-module.nix + system.activationScripts.applications.text = lib.mkAfter '' + install -o root -g wheel -m0555 -D \ + ${lib.getExe pkgs._1password-cli} /usr/local/bin/op + ''; + }; +} + From c36b57f2191bf5c69235765f14a2f3dc9d4fdaee Mon Sep 17 00:00:00 2001 From: Michael Hoang Date: Thu, 8 May 2025 20:07:12 +1000 Subject: [PATCH 2/2] programs/_1password-gui: init module --- modules/module-list.nix | 1 + modules/programs/_1password-gui.nix | 49 +++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 modules/programs/_1password-gui.nix diff --git a/modules/module-list.nix b/modules/module-list.nix index a6c2d12..f0b1d3d 100644 --- a/modules/module-list.nix +++ b/modules/module-list.nix @@ -100,6 +100,7 @@ ./services/nextdns ./services/jankyborders ./programs/_1password.nix + ./programs/_1password-gui.nix ./programs/bash ./programs/direnv.nix ./programs/fish.nix diff --git a/modules/programs/_1password-gui.nix b/modules/programs/_1password-gui.nix new file mode 100644 index 0000000..8ae45e2 --- /dev/null +++ b/modules/programs/_1password-gui.nix @@ -0,0 +1,49 @@ +{ + config, + pkgs, + lib, + ... +}: + +let + cfg = config.programs._1password-gui; +in +{ + options = { + programs._1password-gui = { + enable = lib.mkEnableOption "the 1Password GUI application"; + + package = lib.mkPackageOption pkgs "1Password GUI" { + default = [ "_1password-gui" ]; + }; + }; + }; + + config = lib.mkIf cfg.enable { + # Based on https://github.com/reckenrode/nixos-configs/blob/22b8357fc6ffbd0df5ce50dc417c23a807a268a2/modules/by-name/1p/1password/darwin-module.nix + system.activationScripts.applications.text = lib.mkAfter '' + install -o root -g wheel -m0555 -d "/Applications/1Password.app" + + rsyncFlags=( + # mtime is standardized in the nix store, which would leave only file size to distinguish files. + # Thus we need checksums, despite the speed penalty. + --checksum + # Converts all symlinks pointing outside of the copied tree (thus unsafe) into real files and directories. + # This neatly converts all the symlinks pointing to application bundles in the nix store into + # real directories, without breaking any relative symlinks inside of application bundles. + # This is good enough, because the make-symlinks-relative.sh setup hook converts all $out internal + # symlinks to relative ones. + --copy-unsafe-links + --archive + --delete + --chmod=-w + --no-group + --no-owner + ) + + ${lib.getExe pkgs.rsync} "''${rsyncFlags[@]}" \ + ${pkgs._1password-gui}/Applications/1Password.app/ /Applications/1Password.app + ''; + }; +} +