Nix: init

This commit is contained in:
Mihai Fufezan 2024-10-22 08:40:27 +03:00
parent 12ece5c5ae
commit 2d83b10227
Signed by: fufexan
SSH key fingerprint: SHA256:SdnKmEpJrDu1+2UO1QpB/Eg4HKcdDi6n+xSRqFNJVpg
5 changed files with 194 additions and 0 deletions

1
.envrc Normal file
View file

@ -0,0 +1 @@
use flake

67
flake.lock Normal file
View file

@ -0,0 +1,67 @@
{
"nodes": {
"hyprutils": {
"inputs": {
"nixpkgs": [
"nixpkgs"
],
"systems": [
"systems"
]
},
"locked": {
"lastModified": 1727300645,
"narHash": "sha256-OvAtVLaSRPnbXzOwlR1fVqCXR7i+ICRX3aPMCdIiv+c=",
"owner": "hyprwm",
"repo": "hyprutils",
"rev": "3f5293432b6dc6a99f26aca2eba3876d2660665c",
"type": "github"
},
"original": {
"owner": "hyprwm",
"repo": "hyprutils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1728492678,
"narHash": "sha256-9UTxR8eukdg+XZeHgxW5hQA9fIKHsKCdOIUycTryeVw=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "5633bcff0c6162b9e4b5f1264264611e950c8ec7",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"hyprutils": "hyprutils",
"nixpkgs": "nixpkgs",
"systems": "systems"
}
},
"systems": {
"locked": {
"lastModified": 1689347949,
"narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=",
"owner": "nix-systems",
"repo": "default-linux",
"rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default-linux",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

50
flake.nix Normal file
View file

@ -0,0 +1,50 @@
{
description = "A polkit authentication agent written in QT/QML";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
systems.url = "github:nix-systems/default-linux";
hyprutils = {
url = "github:hyprwm/hyprutils";
inputs.nixpkgs.follows = "nixpkgs";
inputs.systems.follows = "systems";
};
};
outputs = {
self,
nixpkgs,
systems,
...
} @ inputs: let
inherit (nixpkgs) lib;
eachSystem = lib.genAttrs (import systems);
pkgsFor = eachSystem (
system:
import nixpkgs {
localSystem = system;
overlays = [self.overlays.default];
}
);
in {
overlays = import ./nix/overlays.nix {inherit inputs self lib;};
packages = eachSystem (system: {
default = self.packages.${system}.hyprpolkitagent;
inherit (pkgsFor.${system}) hyprpolkitagent;
});
devShells = eachSystem (system: {
default = pkgsFor.${system}.mkShell {
inputsFrom = [self.packages.${system}.hyprpolkitagent];
shellHook = ''
# Generate compile_commands.json
CMAKE_EXPORT_COMPILE_COMMANDS=1 cmake -S . -B ./build
ln -s build/compile_commands.json .
'';
};
});
};
}

51
nix/default.nix Normal file
View file

@ -0,0 +1,51 @@
{
lib,
stdenv,
cmake,
pkg-config,
hyprutils,
kdePackages,
polkit,
qt6,
version ? "0",
}: let
inherit (lib.sources) cleanSource cleanSourceWith;
inherit (lib.strings) hasSuffix;
in
stdenv.mkDerivation {
pname = "hyprpolkitagent";
inherit version;
src = cleanSourceWith {
filter = name: _type: let
baseName = baseNameOf (toString name);
in
! (hasSuffix ".nix" baseName);
src = cleanSource ../.;
};
nativeBuildInputs = [
cmake
pkg-config
qt6.wrapQtAppsHook
];
buildInputs = [
hyprutils
kdePackages.kirigami-addons
kdePackages.polkit-qt-1
polkit
qt6.qtbase
qt6.qtsvg
qt6.qtwayland
];
meta = {
description = "A polkit authentication agent written in QT/QML";
homepage = "https://github.com/hyprwm/hyprpolkitagent";
license = lib.licenses.bsd3;
maintainers = [lib.maintainers.fufexan];
mainProgram = "hyprpolkitagent";
platforms = lib.platforms.linux;
};
}

25
nix/overlays.nix Normal file
View file

@ -0,0 +1,25 @@
{
inputs,
self,
lib,
}: let
mkDate = longDate: (lib.concatStringsSep "-" [
(builtins.substring 0 4 longDate)
(builtins.substring 4 2 longDate)
(builtins.substring 6 2 longDate)
]);
date = mkDate (self.lastModifiedDate or "19700101");
version = lib.removeSuffix "\n" (builtins.readFile ../VERSION);
in {
default = self.overlays.hyprpolkitagent;
hyprpolkitagent = lib.composeManyExtensions [
inputs.hyprutils.overlays.default
(final: prev: {
hyprpolkitagent = final.callPackage ./. {
stdenv = final.gcc14Stdenv;
version = "${version}+date=${date}_${self.shortRev or "dirty"}";
};
})
];
}