Greetings all. I’m pretty new to Nix/NixOS and was wondering if I could get some feedback on adding a flake.nix to a few small CLI projects of mine. One is actually packaged already in nixpkgs (networkmanager_dmenu…not by me!).
- Is it worth it to add a flake.nix to the project, mostly just to show Nix support?
- If it is worth it, can I get some feedback on the following flake? Anything that could be done better or different?
{
description = "Manage NetworkManager connections with dmenu/rofi/wofi instead of nm-applet";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs";
};
outputs = {
self,
nixpkgs,
}: let
systems = ["x86_64-linux"];
forAllSystems = f:
nixpkgs.lib.genAttrs systems (system:
f {
pkgs = import nixpkgs {inherit system;};
});
in {
devShells = forAllSystems ({pkgs}: {
default = pkgs.mkShell {
packages = builtins.attrValues {
inherit
(pkgs)
glib
gobject-introspection
networkmanager
;
inherit
(pkgs.python3Packages)
python
pygobject3
;
};
};
});
packages = forAllSystems ({pkgs}: {
default = pkgs.stdenv.mkDerivation {
name = "networkmanager_dmenu";
pname = "networkmanager_dmenu";
dontBuild = true;
src = ./.;
buildInputs = builtins.attrValues {
inherit
(pkgs)
glib
gobject-introspection
networkmanager
;
inherit
(pkgs.python3Packages)
python
pygobject3
wrapPython
;
};
installPhase = ''
mkdir -p $out/bin $out/share/applications $out/share/doc/$pname
cp networkmanager_dmenu $out/bin/
cp networkmanager_dmenu.desktop $out/share/applications
cp README.md $out/share/doc/$pname/
cp config.ini.example $out/share/doc/$pname/
'';
postFixup = let
inherit (pkgs.python3Packages) pygobject3;
in ''
makeWrapperArgs="\
--prefix GI_TYPELIB_PATH : $GI_TYPELIB_PATH \
--prefix PYTHONPATH : \"$(toPythonPath $out):$(toPythonPath ${pygobject3})\""
wrapPythonPrograms
'';
meta = {
description = "Manage NetworkManager connections with dmenu/rofi/wofi instead of nm-applet";
homepage = "https://github.com/firecat53/networkmanager-dmenu";
license = pkgs.lib.licenses.mit;
maintainers = ["firecat53"];
platforms = pkgs.lib.platforms.all;
};
};
});
};
}
Thanks so much to the package maintainer @jensbin who originally submitted the package to nixpkgs ! I would not have been able to even start this without the work they did!
Thank you!