feat: add flake support

This commit is contained in:
Louis Dalibard 2024-07-10 14:51:39 +02:00
parent cf23eb92bf
commit bd63b0983c

177
flake.nix
View File

@ -6,35 +6,83 @@
}; };
outputs = outputs =
inputs@{ inputs@{ self, nixpkgs, ... }:
self,
nixpkgs,
...
}:
let let
adam-gui-libs = with pkgs; [ adam-gui-libs = with pkgs; [
libGL pkg-config xorg.libX11.dev xorg.libXcursor xorg.libXi xorg.libXinerama xorg.libXrandr xorg.libXxf86vm libGL
]; pkg-config
kon-libs = with pkgs; [ xorg.libX11.dev
pkg-config xorg.libXcursor
]; xorg.libXi
xorg.libXinerama
xorg.libXrandr
xorg.libXxf86vm
];
kon-libs = with pkgs; [ pkg-config ];
pkgs = import nixpkgs { pkgs = import nixpkgs {
system = "x86_64-linux"; system = "x86_64-linux";
overlays = [ self.overlays.default ]; overlays = [ self.overlays.default ];
}; };
in { in
nixosModules.default = ({config, pkgs, ...}: { nixpkgs.overlays = [ self.overlays.default ]; }); {
nixosModules.default = (
{ config, pkgs, ... }:
{
nixpkgs.overlays = [ self.overlays.default ];
}
);
packages.x86_64-linux = rec { packages.x86_64-linux = rec {
inherit (pkgs) inherit (pkgs) kon adam-gui;
kon
adam-gui;
}; };
overlays.default = final: prev: { overlays.default = final: prev: {
kon = kon =
with pkgs; with pkgs;
(buildGoModule rec {
pname = "kon";
version = "0.0.1";
buildInputs = [
gcc
go
] ++ kon-libs;
nativeBuildInputs = with pkgs; [
pkg-config
makeWrapper
];
subPackages = [ "." ];
src = fetchFromGitea {
domain = "git.ontake.dev";
owner = "go";
repo = "kon";
rev = "c94a27dc86c0dbe21f952d247d51b119e66bc6dc";
hash = "sha256-Fi8DkF8lBEdBcOKRKA0Zr9s4NDy1eSrIs9nQS5YA02Q=";
};
vendorHash = null;
meta = with lib; {
description = "A sysadmin tool for monitoring and system updates";
homepage = "https://git.ontake.dev/go/kon";
license = licenses.gpl3;
maintainers = [ ];
platforms = platforms.linux;
};
postInstall = ''
wrapProgram "$out/bin/kon" \
--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath kon-libs}
'';
});
adam-gui = pkgs.symlinkJoin {
name = "adam-gui";
version = "0.0.1";
paths = with pkgs; [
(buildGoModule rec { (buildGoModule rec {
pname = "kon"; pname = "adam-gui";
version = "0.0.1"; version = "0.0.1";
buildInputs = [ buildInputs = [
@ -44,6 +92,7 @@
nativeBuildInputs = with pkgs; [ nativeBuildInputs = with pkgs; [
pkg-config pkg-config
addOpenGLRunpath
makeWrapper makeWrapper
]; ];
@ -52,88 +101,44 @@
src = fetchFromGitea { src = fetchFromGitea {
domain = "git.ontake.dev"; domain = "git.ontake.dev";
owner = "go"; owner = "go";
repo = "kon"; repo = "adam-gui";
rev = "c94a27dc86c0dbe21f952d247d51b119e66bc6dc"; rev = "a64eabcfd4a85d2a3fe3e88c8f668af2c4db741d";
hash = "sha256-Fi8DkF8lBEdBcOKRKA0Zr9s4NDy1eSrIs9nQS5YA02Q="; hash = "sha256-igJie5yYj7LndBGd5XA7GU0qWalrK5j+YM0hCFunXVY=";
}; };
vendorHash = null; vendorHash = null;
meta = with lib; { meta = with lib; {
description = "A sysadmin tool for monitoring and system updates"; description = "A simple GUI for ADAM branded scales";
homepage = "https://git.ontake.dev/go/kon"; homepage = "https://git.ontake.dev/go/adam-gui";
license = licenses.gpl3; license = licenses.gpl3;
maintainers = [ ]; maintainers = [ ];
platforms = platforms.linux; platforms = platforms.linux;
}; };
postInstall = '' postInstall = ''
wrapProgram "$out/bin/kon" \ wrapProgram "$out/bin/adam-gui" \
--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath kon-libs} --prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath adam-gui-libs}
''; '';
});
adam-gui = pkgs.symlinkJoin {
name = "adam-gui";
version = "0.0.1";
paths = with pkgs; [
(buildGoModule rec {
pname = "adam-gui";
version = "0.0.1";
buildInputs = [ postFixup = ''
gcc addOpenGLRunpath $out/bin/adam-gui
go '';
] ++ kon-libs; })
(makeDesktopItem {
nativeBuildInputs = with pkgs; [ name = "ADAM GUI";
pkg-config desktopName = "ADAM GUI";
addOpenGLRunpath exec = "adam-gui";
makeWrapper icon = "adam-gui";
]; comment = "A simple GUI for ADAM branded scales.";
categories = [
subPackages = [ "." ]; "Science"
"Utility"
src = fetchFromGitea { ];
domain = "git.ontake.dev"; })
owner = "go"; ];
repo = "adam-gui";
rev = "a64eabcfd4a85d2a3fe3e88c8f668af2c4db741d";
hash = "sha256-igJie5yYj7LndBGd5XA7GU0qWalrK5j+YM0hCFunXVY=";
};
vendorHash = null;
meta = with lib; {
description = "A simple GUI for ADAM branded scales";
homepage = "https://git.ontake.dev/go/adam-gui";
license = licenses.gpl3;
maintainers = [ ];
platforms = platforms.linux;
};
postInstall = ''
wrapProgram "$out/bin/adam-gui" \
--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath adam-gui-libs}
'';
postFixup = ''
addOpenGLRunpath $out/bin/adam-gui
'';
})
(makeDesktopItem {
name = "ADAM GUI";
desktopName = "ADAM GUI";
exec = "adam-gui";
icon = "adam-gui";
comment = "A simple GUI for ADAM branded scales.";
categories = [
"Science"
"Utility"
];
})
];
};
}; };
};
}; };
} }