From 048a68c029d38e6b64681e55cd03bbcf98f9314f Mon Sep 17 00:00:00 2001 From: Vivian Date: Sun, 24 Mar 2024 12:04:24 +0100 Subject: [PATCH] make target configurable --- flake.lock | 12 ++++++------ flake.nix | 38 +++++++++++++++++++++++++------------- src/main.rs | 1 - 3 files changed, 31 insertions(+), 20 deletions(-) diff --git a/flake.lock b/flake.lock index 66a6297..2ebc417 100644 --- a/flake.lock +++ b/flake.lock @@ -5,11 +5,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1701680307, - "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", "owner": "numtide", "repo": "flake-utils", - "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", "type": "github" }, "original": { @@ -20,11 +20,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1702933230, - "narHash": "sha256-xi8AZ3noIXrgmKLR+ij+CeYFoUTKiQuTLL+aA7FRdRQ=", + "lastModified": 1711276414, + "narHash": "sha256-tID8RCOmMzws4SBrPkZ5oEIpoDaBtF+U2s0zEH6u8Ms=", "owner": "nixos", "repo": "nixpkgs", - "rev": "4e2c5373180ecd17e41e879420be69dc642a6349", + "rev": "11d9b9e97bcb5091c8414bbf9e50eb0d5cd745a9", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 34e4981..3f3dd50 100644 --- a/flake.nix +++ b/flake.nix @@ -5,7 +5,16 @@ }; outputs = { self, nixpkgs, flake-utils }: - flake-utils.lib.eachDefaultSystem (system: + let + buildInputs = pkgs: with pkgs; [ openssl tpm2-tss ]; + nativeBuildInputs = pkgs: + with pkgs; [ + llvmPackages.libclang + llvmPackages.libcxxClang + clang + pkg-config + ]; + in flake-utils.lib.eachDefaultSystem (system: let cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml); pkgs = nixpkgs.legacyPackages.${system}; @@ -19,13 +28,8 @@ doCheck = false; - buildInputs = with pkgs; [ openssl tpm2-tss ]; - nativeBuildInputs = with pkgs; [ - llvmPackages.libclang - llvmPackages.libcxxClang - clang - pkg-config - ]; + buildInputs = buildInputs pkgs; + nativeBuildInputs = nativeBuildInputs pkgs; LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib"; preBuild = '' @@ -55,8 +59,8 @@ devShells.default = pkgs.mkShell { shellHook = "${packages.default.preBuild}"; - inherit (packages.default) - nativeBuildInputs buildInputs LIBCLANG_PATH; + buildInputs = buildInputs pkgs; + nativeBuildInputs = nativeBuildInputs pkgs; }; }) // { nixosModules = rec { @@ -66,16 +70,24 @@ in { options.services.gnome-autounlock-keyring = { enable = mkEnableOption "gnome-autounlock.keyring"; + + target = mkOption { + type = str; + default = "graphical-session.target"; + example = "hyprland-session.target"; + }; }; config = mkIf cfg.enable { systemd.user.services.gnome-autounlock-keyring = { description = "Automatically unlock gnome keyring using TPM"; - wantedBy = [ "gnome-session.target" ]; + wantedBy = [ cfg.target ]; script = '' - ${self.packages.${pkgs.system}.default}/bin/gnome-autounlock-keyring unlock + ${ + self.packages.${pkgs.system}.default + }/bin/gnome-autounlock-keyring unlock ''; - serviceConfig.Type = "oneshot"; + serviceConfig.Type = "oneshot"; }; }; }; diff --git a/src/main.rs b/src/main.rs index 16a5098..12da225 100644 --- a/src/main.rs +++ b/src/main.rs @@ -169,7 +169,6 @@ fn main() -> color_eyre::Result<()> { if res != ControlResult::Ok { bail!("Unlocking failed after {tries}: {res:?}"); } - } else { bail!("password token file not found") }