Skip to content

Commit

Permalink
Nix Housekeeping (#507)
Browse files Browse the repository at this point in the history
* nix: allow overriding flake systems

* nix: get rid of bad `rec` pattern; add `homeManagerModules.ags`

* nix: remove further bad patterns; use mesonBool; add hooks

* ci/nix: use Checkout v4; yml cleanup
  • Loading branch information
NotAShelf authored Jul 18, 2024
1 parent 60c4fdc commit 344ea72
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 109 deletions.
28 changes: 14 additions & 14 deletions .github/workflows/cachix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
18 changes: 17 additions & 1 deletion flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 16 additions & 10 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,35 @@

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 {
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;
};
};
}
173 changes: 89 additions & 84 deletions nix/default.nix
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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];
};
}

0 comments on commit 344ea72

Please sign in to comment.