From 4d0d2dcf622779b5aaa7124efaf58eedda7f8258 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Thu, 18 Jul 2024 06:31:58 +0300 Subject: [PATCH 1/4] nix: allow overriding flake systems --- flake.lock | 18 +++++++++++++++++- flake.nix | 9 +++++---- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/flake.lock b/flake.lock index bb5d5cd8..b62ff7af 100644 --- a/flake.lock +++ b/flake.lock @@ -18,7 +18,23 @@ }, "root": { "inputs": { - "nixpkgs": "nixpkgs" + "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" } } }, diff --git a/flake.nix b/flake.nix index aaca0c42..cfec1dfe 100644 --- a/flake.nix +++ b/flake.nix @@ -3,17 +3,18 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + + # «https://github.com/nix-systems/nix-systems» + systems.url = "github:nix-systems/default-linux"; }; outputs = { nixpkgs, self, + systems, }: let version = builtins.replaceStrings ["\n"] [""] (builtins.readFile ./version); - genSystems = nixpkgs.lib.genAttrs [ - "aarch64-linux" - "x86_64-linux" - ]; + genSystems = nixpkgs.lib.genAttrs (import systems); pkgs = genSystems (system: import nixpkgs {inherit system;}); in { packages = genSystems (system: rec { From 3371cca662a5ee418ad740aa57e2f0bfc8f0f262 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Thu, 18 Jul 2024 06:35:28 +0300 Subject: [PATCH 2/4] nix: get rid of bad `rec` pattern; add `homeManagerModules.ags` --- flake.nix | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/flake.nix b/flake.nix index cfec1dfe..a5fff0bc 100644 --- a/flake.nix +++ b/flake.nix @@ -17,16 +17,21 @@ genSystems = nixpkgs.lib.genAttrs (import systems); pkgs = genSystems (system: import nixpkgs {inherit system;}); in { - packages = genSystems (system: rec { - default = pkgs.${system}.callPackage ./nix {inherit version;}; - ags = default; - agsWithTypes = default; # for backwards compatibility - agsNoTypes = pkgs.${system}.callPackage ./nix { + packages = genSystems (system: let + inherit (pkgs.${system}) callPackage; + in { + default = callPackage ./nix {inherit version;}; + ags = self.packages.${system}.default; + agsWithTypes = self.packages.${system}.default; # for backwards compatibility + agsNoTypes = callPackage ./nix { inherit version; buildTypes = false; }; }); - homeManagerModules.default = import ./nix/hm-module.nix self; + homeManagerModules = { + default = self.homeManagerModules.ags; + ags = import ./nix/hm-module.nix self; + }; }; } From 0486c306e5741be62975c5373fce6de07ac45743 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Thu, 18 Jul 2024 06:41:27 +0300 Subject: [PATCH 3/4] nix: remove further bad patterns; use mesonBool; add hooks --- nix/default.nix | 173 +++++++++++++++++++++++++----------------------- 1 file changed, 89 insertions(+), 84 deletions(-) diff --git a/nix/default.nix b/nix/default.nix index f20f04d7..fbb1e59a 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -1,32 +1,33 @@ -{ lib -, stdenv -, buildNpmPackage -, fetchFromGitLab -, nodePackages -, meson -, pkg-config -, ninja -, gobject-introspection -, gtk3 -, libpulseaudio -, gjs -, wrapGAppsHook -, upower -, gnome -, gtk-layer-shell -, glib-networking -, networkmanager -, libdbusmenu-gtk3 -, gvfs -, libsoup_3 -, libnotify -, pam -, extraPackages ? [ ] -, version ? "git" -, buildTypes ? true -}: +{ + lib, + stdenv, + buildNpmPackage, + fetchFromGitLab, + nodePackages, + meson, + pkg-config, + ninja, + gobject-introspection, + gtk3, + libpulseaudio, + gjs, + wrapGAppsHook, + upower, + gnome, + gtk-layer-shell, + glib-networking, + networkmanager, + libdbusmenu-gtk3, + gvfs, + libsoup_3, + libnotify, + pam, + extraPackages ? [], + version ? "git", + buildTypes ? true, +}: let + pname = "ags"; -let gvc-src = fetchFromGitLab { domain = "gitlab.gnome.org"; owner = "GNOME"; @@ -35,70 +36,74 @@ let sha256 = "sha256-FosJwgTCp6/EI6WVbJhPisokRBA6oT0eo7d+Ya7fFX8="; }; in -stdenv.mkDerivation rec { - pname = "ags"; - inherit version; + stdenv.mkDerivation { + inherit pname version; - src = buildNpmPackage { - name = pname; - src = lib.cleanSource ../.; + src = buildNpmPackage { + name = pname; + src = lib.cleanSource ../.; - dontBuild = true; + dontBuild = true; - npmDepsHash = "sha256-ucWdADdMqAdLXQYKGOXHNRNM9bhjKX4vkMcQ8q/GZ20="; + npmDepsHash = "sha256-ucWdADdMqAdLXQYKGOXHNRNM9bhjKX4vkMcQ8q/GZ20="; - installPhase = '' - mkdir $out - cp -r * $out - ''; - }; + installPhase = '' + runHook preInstall + mkdir $out + cp -r * $out + runHook postInstall + ''; + }; - mesonFlags = [ - "-Dbuild_types=${if buildTypes then "true" else "false"}" - ]; + nativeBuildInputs = [ + pkg-config + meson + ninja + nodePackages.typescript + wrapGAppsHook + gobject-introspection + ]; - prePatch = '' - mkdir -p ./subprojects/gvc - cp -r ${gvc-src}/* ./subprojects/gvc - ''; + buildInputs = + [ + gjs + gtk3 + libpulseaudio + upower + gnome.gnome-bluetooth + gtk-layer-shell + glib-networking + networkmanager + libdbusmenu-gtk3 + gvfs + libsoup_3 + libnotify + pam + ] + ++ extraPackages; - postPatch = '' - chmod +x post_install.sh - patchShebangs post_install.sh - ''; + mesonFlags = [ + (lib.mesonBool "build_types" buildTypes) + ]; - nativeBuildInputs = [ - pkg-config - meson - ninja - nodePackages.typescript - wrapGAppsHook - gobject-introspection - ]; + prePatch = '' + mkdir -p ./subprojects/gvc + cp -r ${gvc-src}/* ./subprojects/gvc + ''; - buildInputs = [ - gjs - gtk3 - libpulseaudio - upower - gnome.gnome-bluetooth - gtk-layer-shell - glib-networking - networkmanager - libdbusmenu-gtk3 - gvfs - libsoup_3 - libnotify - pam - ] ++ extraPackages; + postPatch = '' + chmod +x post_install.sh + patchShebangs post_install.sh + ''; - outputs = [ "out" "lib" ]; + outputs = ["out" "lib"]; - meta = with lib; { - description = "A customizable and extensible shell"; - homepage = "https://github.com/Aylur/ags"; - platforms = [ "x86_64-linux" "aarch64-linux" ]; - license = licenses.gpl3; - meta.maintainers = [ lib.maintainers.Aylur ]; - }; -} + meta = { + description = "A customizable and extensible shell"; + homepage = "https://github.com/Aylur/ags"; + changelog = "https://github.com/Aylur/ags/blob/${version}/CHANGELOG.md"; + platforms = ["x86_64-linux" "aarch64-linux"]; + license = lib.licenses.gpl3; + meta.maintainers = [lib.maintainers.Aylur]; + }; + } From 9c5201ac60b391624006fcab9955c260ea5f2fd0 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Thu, 18 Jul 2024 06:53:27 +0300 Subject: [PATCH 4/4] ci/nix: use Checkout v4; yml cleanup --- .github/workflows/cachix.yml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/cachix.yml b/.github/workflows/cachix.yml index 9f035354..4a4660e5 100644 --- a/.github/workflows/cachix.yml +++ b/.github/workflows/cachix.yml @@ -6,19 +6,19 @@ jobs: name: "Build" runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v3 - with: - submodules: recursive + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive - - uses: cachix/install-nix-action@v25 - - uses: DeterminateSystems/magic-nix-cache-action@main - - uses: cachix/cachix-action@v12 - with: - name: ags - authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' + - uses: cachix/install-nix-action@v25 + - uses: DeterminateSystems/magic-nix-cache-action@main + - uses: cachix/cachix-action@v12 + with: + name: ags + authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" - - name: Build ags - run: | - nix build --print-build-logs - nix build --print-build-logs .#agsWithTypes + - name: Build ags + run: | + nix build --print-build-logs + nix build --print-build-logs .#agsWithTypes