gnome-autounlock-keyring/flake.nix

86 lines
3 KiB
Nix
Raw Normal View History

2023-12-18 22:29:13 +01:00
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
2023-12-19 09:00:07 +01:00
cargoToml = (builtins.fromTOML (builtins.readFile ./Cargo.toml));
2023-12-18 22:29:13 +01:00
pkgs = nixpkgs.legacyPackages.${system};
inherit (pkgs) stdenv lib;
2023-12-19 09:00:07 +01:00
in rec {
packages.default = pkgs.rustPlatform.buildRustPackage {
pname = cargoToml.package.name;
version = cargoToml.package.version;
src = self;
cargoLock.lockFile = ./Cargo.lock;
doCheck = false;
2023-12-19 10:21:13 +01:00
buildInputs = with pkgs; [ openssl tpm2-tss ];
2023-12-18 22:29:13 +01:00
nativeBuildInputs = with pkgs; [
llvmPackages.libclang
llvmPackages.libcxxClang
clang
2023-12-19 09:00:07 +01:00
pkg-config
2023-12-18 22:29:13 +01:00
];
LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
2023-12-19 09:00:07 +01:00
preBuild = ''
export BINDGEN_EXTRA_CLANG_ARGS="$(< ${stdenv.cc}/nix-support/libc-crt1-cflags) \
$(< ${stdenv.cc}/nix-support/libc-cflags) \
$(< ${stdenv.cc}/nix-support/cc-cflags) \
$(< ${stdenv.cc}/nix-support/libcxx-cxxflags) \
${
lib.optionalString stdenv.cc.isClang
"-idirafter ${stdenv.cc.cc}/lib/clang/${
lib.getVersion stdenv.cc.cc
}/include"
} \
${
lib.optionalString stdenv.cc.isGNU
"-isystem ${stdenv.cc.cc}/include/c++/${
lib.getVersion stdenv.cc.cc
} -isystem ${stdenv.cc.cc}/include/c++/${
lib.getVersion stdenv.cc.cc
}/${stdenv.hostPlatform.config} -idirafter ${stdenv.cc.cc}/lib/gcc/${stdenv.hostPlatform.config}/${
lib.getVersion stdenv.cc.cc
}/include"
} \
"
'';
};
2023-12-19 10:21:13 +01:00
devShells.default = pkgs.mkShell {
2023-12-19 09:00:07 +01:00
shellHook = "${packages.default.preBuild}";
2023-12-19 12:27:50 +01:00
inherit (packages.default)
nativeBuildInputs buildInputs LIBCLANG_PATH;
2023-12-18 22:29:13 +01:00
};
2023-12-19 12:27:50 +01:00
}) // {
nixosModules = rec {
default = { config, lib, pkgs, ... }:
with lib;
let cfg = config.services.gnome-autounlock-keyring;
in {
options.services.gnome-autounlock-keyring = {
enable = mkEnableOption "gnome-autounlock.keyring";
};
config = mkIf cfg.enable {
systemd.user.services.gnome-autounlock-keyring = {
description = "Automatically unlock gnome keyring using TPM";
wantedBy = [ "gnome-session.target" ];
script = ''
${self.packages.${pkgs.system}.default}/bin/gnome-autounlock-keyring unlock
'';
serviceConfig = { Type = "oneshot"; };
};
};
};
gnome-autounlock-keyring = default;
};
};
2023-12-18 22:29:13 +01:00
}