diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..c7f1642 --- /dev/null +++ b/flake.lock @@ -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 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..519c7ca --- /dev/null +++ b/flake.nix @@ -0,0 +1,38 @@ +{ + description = "A tiny qt6/qml application to display information about the running system"; + + 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}.hyprsysteminfo; + inherit (pkgsFor.${system}) hyprsysteminfo; + }); + }; +} diff --git a/nix/default.nix b/nix/default.nix new file mode 100644 index 0000000..1dc1ddf --- /dev/null +++ b/nix/default.nix @@ -0,0 +1,48 @@ +{ + lib, + stdenv, + cmake, + pkg-config, + hyprutils, + kdePackages, + qt6, + version ? "0", +}: let + inherit (lib.sources) cleanSource cleanSourceWith; + inherit (lib.strings) hasSuffix; +in + stdenv.mkDerivation { + pname = "hyprsysteminfo"; + 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 + qt6.qtbase + qt6.qtsvg + qt6.qtwayland + ]; + + meta = { + description = "A tiny qt6/qml application to display information about the running system"; + homepage = "https://github.com/hyprwm/hyprsysteminfo"; + license = lib.licenses.bsd3; + maintainers = [lib.maintainers.fufexan]; + mainProgram = "hyprsysteminfo"; + platforms = lib.platforms.linux; + }; + } diff --git a/nix/overlays.nix b/nix/overlays.nix new file mode 100644 index 0000000..61f57f9 --- /dev/null +++ b/nix/overlays.nix @@ -0,0 +1,24 @@ +{ + 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.hyprsysteminfo; + + hyprsysteminfo = lib.composeManyExtensions [ + inputs.hyprutils.overlays.default + (final: prev: { + hyprsysteminfo = final.callPackage ./. { + version = "${version}+date=${date}_${self.shortRev or "dirty"}"; + }; + }) + ]; +}