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" "systems": "systems"
}, },
"locked": { "locked": {
"lastModified": 1701680307, "lastModified": 1710146030,
"narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide", "owner": "numtide",
"repo": "flake-utils", "repo": "flake-utils",
"rev": "4022d587cbbfd70fe950c1e2083a02621806a725", "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -20,11 +20,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1702933230, "lastModified": 1711276414,
"narHash": "sha256-xi8AZ3noIXrgmKLR+ij+CeYFoUTKiQuTLL+aA7FRdRQ=", "narHash": "sha256-tID8RCOmMzws4SBrPkZ5oEIpoDaBtF+U2s0zEH6u8Ms=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "4e2c5373180ecd17e41e879420be69dc642a6349", "rev": "11d9b9e97bcb5091c8414bbf9e50eb0d5cd745a9",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

@ -5,7 +5,16 @@
}; };
outputs = { self, nixpkgs, flake-utils }: 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 let
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml); cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
pkgs = nixpkgs.legacyPackages.${system}; pkgs = nixpkgs.legacyPackages.${system};
@ -19,13 +28,8 @@
doCheck = false; doCheck = false;
buildInputs = with pkgs; [ openssl tpm2-tss ]; buildInputs = buildInputs pkgs;
nativeBuildInputs = with pkgs; [ nativeBuildInputs = nativeBuildInputs pkgs;
llvmPackages.libclang
llvmPackages.libcxxClang
clang
pkg-config
];
LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib"; LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
preBuild = '' preBuild = ''
@ -55,8 +59,8 @@
devShells.default = pkgs.mkShell { devShells.default = pkgs.mkShell {
shellHook = "${packages.default.preBuild}"; shellHook = "${packages.default.preBuild}";
inherit (packages.default) buildInputs = buildInputs pkgs;
nativeBuildInputs buildInputs LIBCLANG_PATH; nativeBuildInputs = nativeBuildInputs pkgs;
}; };
}) // { }) // {
nixosModules = rec { nixosModules = rec {
@ -66,16 +70,24 @@
in { in {
options.services.gnome-autounlock-keyring = { options.services.gnome-autounlock-keyring = {
enable = mkEnableOption "gnome-autounlock.keyring"; enable = mkEnableOption "gnome-autounlock.keyring";
target = mkOption {
type = str;
default = "graphical-session.target";
example = "hyprland-session.target";
};
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
systemd.user.services.gnome-autounlock-keyring = { systemd.user.services.gnome-autounlock-keyring = {
description = "Automatically unlock gnome keyring using TPM"; description = "Automatically unlock gnome keyring using TPM";
wantedBy = [ "gnome-session.target" ]; wantedBy = [ cfg.target ];
script = '' 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 { if res != ControlResult::Ok {
bail!("Unlocking failed after {tries}: {res:?}"); bail!("Unlocking failed after {tries}: {res:?}");
} }
} else { } else {
bail!("password token file not found") bail!("password token file not found")
} }