-
Notifications
You must be signed in to change notification settings - Fork 21
Clean up the Nix flake, recommended practices, provide overlay #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
c85d8b9
4e9e3ab
3dbfeee
f5aef0b
35b4ac8
fabe645
9fb310f
8841ba2
29aef1d
5b9e5fa
9c8d7f6
589b98c
4ae5988
8a95f2c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,58 +1,60 @@ | ||
| { | ||
| description = "brain"; | ||
| inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; | ||
| description = "A script to patch the MonoLisa font with Nerd Fonts glyphs."; | ||
|
|
||
| outputs = inputs @ { | ||
| inputs = { | ||
| nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; | ||
| systems.url = "github:nix-systems/default"; | ||
| }; | ||
|
|
||
| outputs = { | ||
| self, | ||
| nixpkgs, | ||
| systems, | ||
| }: let | ||
| inherit (nixpkgs.lib) genAttrs; | ||
| forAllSystems = f: | ||
| genAttrs | ||
| ["x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin"] | ||
| (system: f nixpkgs.legacyPackages.${system}); | ||
| inherit (nixpkgs.lib) genAttrs makeBinPath; | ||
| eachSystem = fn: | ||
| genAttrs (import systems) | ||
| (system: | ||
| fn system | ||
| (import nixpkgs { | ||
| localSystem.system = system; | ||
| overlays = [self.overlays.default]; | ||
| })); | ||
| in { | ||
| packages = forAllSystems ( | ||
| pkgs: | ||
| with pkgs; { | ||
| default = stdenv.mkDerivation { | ||
| name = "monolisa-nerdfont-patch"; | ||
| src = ./.; | ||
| nativeBuildInputs = [ makeWrapper ]; | ||
| buildInputs = [ | ||
| fontforge | ||
| python3 | ||
| ]; | ||
| unpackPhase = ":"; | ||
| buildPhase = ":"; | ||
| installPhase = '' | ||
| mkdir -p $out/bin | ||
| install -m755 -D ${./patch-monolisa} $out/bin/monolisa-nerdfont-patch | ||
| install -m755 -D ${./font-patcher} $out/bin/font-patcher | ||
| cp -r ${./bin} $out/bin/bin | ||
| cp -r ${./src} $out/bin/src | ||
| ''; | ||
| postFixup = '' | ||
| wrapProgram $out/bin/monolisa-nerdfont-patch \ | ||
| --set PATH ${lib.makeBinPath [ | ||
| fontforge | ||
| ]} | ||
| overlays = { | ||
| default = final: _prev: let | ||
| pkgs = final; | ||
| in { | ||
| monolisa-nerdfont-patch = pkgs.stdenv.mkDerivation { | ||
| name = "monolisa-nerdfont-patch"; | ||
| src = ./.; | ||
| nativeBuildInputs = with pkgs; [makeWrapper]; | ||
| buildInputs = with pkgs; [fontforge python3]; | ||
| buildPhase = ":"; | ||
| installPhase = '' | ||
| mkdir -p $out/bin | ||
| install -m755 -D ${./patch-monolisa} $out/bin/monolisa-nerdfont-patch | ||
| install -m755 -D ${./font-patcher} $out/bin/font-patcher | ||
| cp -r ${./bin} $out/bin/bin | ||
| cp -r ${./src} $out/bin/src | ||
| ''; | ||
| postFixup = '' | ||
| wrapProgram $out/bin/monolisa-nerdfont-patch \ | ||
| --set PATH ${makeBinPath (with final; [fontforge])} | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is subjective, and I understand that it is preference, but parts of Nixpkgs are moving away from this, which is why I changed it. The idea is to keep it clear what is in
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps the issue I am thinking of in Nixpkgs is the over-usage of |
||
| ''; | ||
| }; | ||
| }; | ||
| } | ||
| ); | ||
| }; | ||
|
|
||
| devShells = forAllSystems ( | ||
| pkgs: | ||
| with pkgs; { | ||
| default = mkShell { | ||
| buildInputs = [ | ||
| fontforge | ||
| python3 | ||
| pre-commit | ||
| ]; | ||
| }; | ||
| } | ||
| ); | ||
| packages = eachSystem (system: pkgs: { | ||
| default = self.packages.${system}.monolisa-nerdfont-patch; | ||
| monolisa-nerdfont-patch = pkgs.monolisa-nerdfont-patch; | ||
| }); | ||
|
|
||
| devShells = eachSystem (_: pkgs: { | ||
| default = pkgs.mkShell { | ||
| buildInputs = with pkgs; [fontforge python3 pre-commit]; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Question, not a suggestion or correction: why did you choose to use buildInputs over packages? Now a little pushy:
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It make no difference they are all just merged. |
||
| }; | ||
| }); | ||
| }; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand not wanting to take the formatter's flake as an input, however consider re-introducing the
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am well aware of how |
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just noticed, this change is bad, don't ever use an external
pkgsfrom inside an overlay. You should treatfinalas if it werepkgs, otherwise you evaluate Nixpkgs stages twice. See here for some relevant discussion.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never mind the above comment. I now see line 26. If this is your preference (and you should be consistent with your change on lines 16-22) consider using the naming scheme that I have come up with in the thread I have already linked. It does make sense to rename
finaltopkgs, but asfinal/selfandprev/supercan also be used foroverrideAttrs(and others) inside overlays, to avoid shadowing, considerpkgs: pkgs0.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For one they aren't used within this overlay so avoiding name confusion is a moot point. And secondly, your scheme is incompatible with
nix flake checkas I previously demonstrated when you first submitted a PR with this change.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No,
nixfmtcaused the check failure. Not this.