fix build

This commit is contained in:
Vivian 2024-12-23 18:31:20 +01:00
parent 06279869e7
commit e0d291465b
2 changed files with 64 additions and 66 deletions

View file

@ -5,11 +5,11 @@
"systems": "systems" "systems": "systems"
}, },
"locked": { "locked": {
"lastModified": 1710146030, "lastModified": 1731533236,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide", "owner": "numtide",
"repo": "flake-utils", "repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -20,11 +20,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1711276414, "lastModified": 1734973338,
"narHash": "sha256-tID8RCOmMzws4SBrPkZ5oEIpoDaBtF+U2s0zEH6u8Ms=", "narHash": "sha256-E9JOCwppN3WX9oh6kV9w4nkN+6UPGNdzljscdJy5kTs=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "11d9b9e97bcb5091c8414bbf9e50eb0d5cd745a9", "rev": "2b37ecedbb948e7607307c56e35aea5155eb65a7",
"type": "github" "type": "github"
}, },
"original": { "original": {

118
flake.nix
View file

@ -4,22 +4,36 @@
flake-utils.url = "github:numtide/flake-utils"; flake-utils.url = "github:numtide/flake-utils";
}; };
outputs = { self, nixpkgs, flake-utils }: outputs =
{
self,
nixpkgs,
flake-utils,
}:
let let
buildInputs = pkgs: with pkgs; [ openssl tpm2-tss ]; buildInputs =
nativeBuildInputs = pkgs: pkgs: with pkgs; [
with pkgs; [ openssl
tpm2-tss
];
nativeBuildInputs =
pkgs: with pkgs; [
llvmPackages.libclang llvmPackages.libclang
llvmPackages.clang
llvmPackages.libcxxClang llvmPackages.libcxxClang
clang clang
pkg-config pkg-config
rustPlatform.bindgenHook
]; ];
in flake-utils.lib.eachDefaultSystem (system: 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};
inherit (pkgs) stdenv lib; inherit (pkgs) stdenv lib;
in rec { in
rec {
packages.default = pkgs.rustPlatform.buildRustPackage { packages.default = pkgs.rustPlatform.buildRustPackage {
pname = cargoToml.package.name; pname = cargoToml.package.name;
version = cargoToml.package.version; version = cargoToml.package.version;
@ -30,68 +44,52 @@
buildInputs = buildInputs pkgs; buildInputs = buildInputs pkgs;
nativeBuildInputs = nativeBuildInputs pkgs; nativeBuildInputs = nativeBuildInputs pkgs;
LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib"; # LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
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"
} \
"
'';
}; };
devShells.default = pkgs.mkShell { devShells.default = pkgs.mkShell {
shellHook = "${packages.default.preBuild}"; # shellHook = "${packages.default.preBuild}";
buildInputs = buildInputs pkgs; buildInputs = buildInputs pkgs;
nativeBuildInputs = nativeBuildInputs pkgs; nativeBuildInputs = nativeBuildInputs pkgs;
}; };
}) // { }
nixosModules = rec { )
default = { config, lib, pkgs, ... }: // {
with lib; nixosModules = rec {
let cfg = config.services.gnome-autounlock-keyring; default =
in { {
options.services.gnome-autounlock-keyring = { config,
enable = mkEnableOption "gnome-autounlock.keyring"; lib,
pkgs,
...
}:
with lib;
let
cfg = config.services.gnome-autounlock-keyring;
in
{
options.services.gnome-autounlock-keyring = {
enable = mkEnableOption "gnome-autounlock.keyring";
target = mkOption { target = mkOption {
type = types.str; type = types.str;
default = "graphical-session.target"; default = "graphical-session.target";
example = "hyprland-session.target"; example = "hyprland-session.target";
};
};
config = mkIf cfg.enable {
systemd.user.services.gnome-autounlock-keyring = {
description = "Automatically unlock gnome keyring using TPM";
wantedBy = [ cfg.target ];
script = ''
${
self.packages.${pkgs.system}.default
}/bin/gnome-autounlock-keyring unlock
'';
serviceConfig.Type = "oneshot";
};
}; };
}; };
gnome-autounlock-keyring = default;
}; config = mkIf cfg.enable {
systemd.user.services.gnome-autounlock-keyring = {
description = "Automatically unlock gnome keyring using TPM";
wantedBy = [ cfg.target ];
script = ''
${self.packages.${pkgs.system}.default}/bin/gnome-autounlock-keyring unlock
'';
serviceConfig.Type = "oneshot";
};
};
};
gnome-autounlock-keyring = default;
}; };
};
} }