Skip to content

Commit

Permalink
flake: update & cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
chayleaf committed Dec 1, 2023
1 parent 1572bc8 commit 2e2cb67
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 156 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,7 @@ packagecache
*.out
*.app
/.direnv/

# Nix
result
result-*
99 changes: 7 additions & 92 deletions flake.lock

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

83 changes: 27 additions & 56 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,19 @@

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
devshell.url = "github:numtide/devshell";
flake-utils.url = "github:numtide/flake-utils";
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
};

outputs = { self, flake-utils, devshell, nixpkgs, flake-compat }:
outputs = { self, nixpkgs, ... }:
let
inherit (nixpkgs) lib;
genSystems = lib.genAttrs [
genSystems = func: lib.genAttrs [
"x86_64-linux"
"aarch64-linux"
];

pkgsFor = genSystems (system:
import nixpkgs {
inherit system;
});
] (system: func (import nixpkgs { inherit system; }));

mkDate = longDate: (lib.concatStringsSep "-" [
(builtins.substring 0 4 longDate)
Expand All @@ -33,58 +26,36 @@
{
overlays.default = final: prev: {
waybar = final.callPackage ./nix/default.nix {
version = prev.waybar.version + "+date=" + (mkDate (self.lastModifiedDate or "19700101")) + "_" + (self.shortRev or "dirty");
# take the first "version: '...'" from meson.build
version =
(builtins.head (builtins.split "'"
(builtins.elemAt
(builtins.split " version: '" (builtins.readFile ./meson.build))
2)))
+ "+date=" + (mkDate (self.lastModifiedDate or "19700101")) + "_" + (self.shortRev or "dirty");
};
};
packages = genSystems
(system:
(self.overlays.default pkgsFor.${system} pkgsFor.${system})
// {
default = self.packages.${system}.waybar;
});
packages = genSystems (pkgs:
let packages = self.overlays.default pkgs pkgs;
in packages // {
default = packages.waybar;
});
} //
flake-utils.lib.eachDefaultSystem (system: {
devShell =
let pkgs = import nixpkgs {
inherit system;

overlays = [ devshell.overlays.default ];
};
in
pkgs.devshell.mkShell {
imports = [ "${pkgs.devshell.extraModulesDir}/language/c.nix" ];

devshell.packages = with pkgs; [
genSystems (pkgs: {
devShells.default =
pkgs.mkShell {
name = "waybar-shell";

# most of these aren't actually used in the waybar derivation, this is just in case
# they will ever start being used
inherit (pkgs.waybar) buildInputs depsBuildBuild depsBuildBuildPropagated depsBuildTarget
depsBuildTargetPropagated depsHostHost depsHostHostPropagated depsTargetTarget
depsTargetTargetPropagated propagatedBuildInputs propagatedNativeBuildInputs strictDeps;

nativeBuildInputs = pkgs.waybar.nativeBuildInputs ++ (with pkgs; [
clang-tools
gdb
# from nativeBuildInputs
gnumake
meson
ninja
pkg-config
scdoc
] ++ (map lib.getDev [
# from buildInputs
wayland wlroots gtkmm3 libsigcxx jsoncpp spdlog gtk-layer-shell howard-hinnant-date libxkbcommon
# optional dependencies
gobject-introspection glib playerctl python3.pkgs.pygobject3
libevdev libinput libjack2 libmpdclient playerctl libnl
libpulseaudio sndio sway libdbusmenu-gtk3 udev upower wireplumber

# from propagated build inputs?
at-spi2-atk atkmm cairo cairomm catch2 fmt_8 fontconfig
gdk-pixbuf glibmm gtk3 harfbuzz pango pangomm wayland-protocols
]);

env = with pkgs; [
{ name = "CPLUS_INCLUDE_PATH"; prefix = "$DEVSHELL_DIR/include"; }
{ name = "PKG_CONFIG_PATH"; prefix = "$DEVSHELL_DIR/lib/pkgconfig"; }
{ name = "PKG_CONFIG_PATH"; prefix = "$DEVSHELL_DIR/share/pkgconfig"; }
{ name = "PATH"; prefix = "${wayland.bin}/bin"; }
{ name = "LIBRARY_PATH"; prefix = "${lib.getLib sndio}/lib"; }
{ name = "LIBRARY_PATH"; prefix = "${lib.getLib zlib}/lib"; }
{ name = "LIBRARY_PATH"; prefix = "${lib.getLib howard-hinnant-date}/lib"; }
];
};
});
}
9 changes: 1 addition & 8 deletions nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,9 @@

waybar.overrideAttrs (prev: {
inherit version;
# version = "0.9.17";

src = lib.cleanSourceWith {
filter = name: type:
let
baseName = baseNameOf (toString name);
in
! (
lib.hasSuffix ".nix" baseName
);
filter = name: type: type != "regular" || !lib.hasSuffix ".nix" name;
src = lib.cleanSource ../.;
};
})

0 comments on commit 2e2cb67

Please sign in to comment.