make target configurable

This commit is contained in:
Vivian 2024-03-24 12:04:24 +01:00
parent 84f3dd55ef
commit 048a68c029
3 changed files with 31 additions and 20 deletions

View file

@ -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": {

View file

@ -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";
};
};
};

View file

@ -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")
}