Hi I’m having some issues with a program I’m running, and would like to add some additional debugging.
So I forked the github repo and added some logging, but how would I go about changing the source repo used to build the program?
The program is nixpkgs/pkgs/by-name/fl/flex-launcher/package.nix at d916df777523d75f7c5acca79946652f032f633e · NixOS/nixpkgs · GitHub and I would like to build from GitHub - AnderssonPeter/flex-launcher: A customizable HTPC application launcher for Windows and Linux instead
I have tried to use overlays
# Overlay to set custom autostart script for openbox
nixpkgs.overlays = with pkgs; [
flex-launcher = super.flex-launcher.src.overrideAttrs (oldAttrs: rec {
owner = "AnderssonPeter";
repo = "flex-launcher";
# Generated using nix-prefetch-github
rev = "be36128d5c2536daa194dc5b50c13bb91239df5a";
# Generated using nix-prefetch-github
hash = "sha256-cS2G2muoZctw7Dj/5mhKdj2Y0t9gDP35OiNXPAnDKQ8=";
});
})
];
in combination with
users = {
users = {
htpc = {
packages = with pkgs; [
flex-launcher
];
};
};
};
But when I run sudo nixos-rebuild switch the program isn’t located in /etc/profiles/per-user/htpc/bin anymore, what am I missing?
Use override not overrideAttrs. also remove the with pkgs;, that makes no sense in the context of an overlay that is already giving you two nixpkgs instances.
EDIT: and you overrode the package to just its src, which didn’t build anything, it’s just fetching.
1 Like
Thanks the following worked
nixpkgs.overlays = [
(final: prev: {
flex-launcher = prev.flex-launcher.overrideAttrs (old: {
src = prev.fetchFromGitHub {
owner = "AnderssonPeter";
repo = "flex-launcher";
rev = "381ea7a4e2605731c592ccffd86ff4c27ff725d4";
hash = "sha256-O4D+B1kjJWQemRg+5oya8e13tvl3o/q15kwYIX8Xd6c=";
};
});
})
];
If you do it that way, use final.fetchFromGitHub. (Always prefer final if possible.)
Just out of curiosity what is the reason for this?
If fetchFromGitHub was changed in any overlay (including the current one ) you’d want the actual final one.
And depending on the attribute you’re using, you can get the wrong result when you don’t use final (I’ll link an example thread if I find it).
I tried to PR it to the docs but it didn’t go anywhere.
master ← eclairevoyant:doc-overlays
opened 05:41AM - 31 Mar 24 UTC
## Description of changes
The motivation for this change is to correct a long… standing error in the docs, suggesting that functions should come from `super`.
In fact, functions should come from `self` precisely because you want to use the final version of said function.
Moreover, when these functions are builders, you want your overlays to actually take effect!
As an example, this overlay results in infrec, because `xz` is part of `stdenv`, which is used by `fetchurl`:
```nix
final: prev: {
xz = prev.xz.overrideAttrs (finalAttrs: prevAttrs: {
version = "5.4.6";
src = prev.fetchurl {
url = "mirror://sourceforge/lzmautils/xz-${finalAttrs.version}.tar.bz2";
hash = "sha256-kThRsnTo4dMXgeyUnxwj6NvPDs9uc6JDbcIXad0+b0k=";
};
});
}
```
While this one works as expected (the only change being to pull `fetchurl` from `self` aka `final`, rather than `super` aka `prev`):
```nix
final: prev: {
xz = prev.xz.overrideAttrs (finalAttrs: prevAttrs: {
version = "5.4.6";
src = final.fetchurl {
url = "mirror://sourceforge/lzmautils/xz-${finalAttrs.version}.tar.bz2";
hash = "sha256-kThRsnTo4dMXgeyUnxwj6NvPDs9uc6JDbcIXad0+b0k=";
};
});
}
```
The original reason for the suggestion to use functions from `super` came from a 2017 talk on the topic, but with no explanation provided. Further investigation reveals this suggestion was related to a feature known as "automatic grafting" (currently nonexistent in nixpkgs). Given that functions should in fact come from `self`, it's likely the feature itself had some design flaws, and as it was never merged, we can safely correct this documentation.
## Things done
- Built on platform(s)
- [ ] x86_64-linux
- [ ] aarch64-linux
- [ ] x86_64-darwin
- [ ] aarch64-darwin
- For non-Linux: Is sandboxing enabled in `nix.conf`? (See [Nix manual](https://nixos.org/manual/nix/stable/command-ref/conf-file.html))
- [ ] `sandbox = relaxed`
- [ ] `sandbox = true`
- [ ] Tested, as applicable:
- [NixOS test(s)](https://nixos.org/manual/nixos/unstable/index.html#sec-nixos-tests) (look inside [nixos/tests](https://github.com/NixOS/nixpkgs/blob/master/nixos/tests))
- and/or [package tests](https://nixos.org/manual/nixpkgs/unstable/#sec-package-tests)
- or, for functions and "core" functionality, tests in [lib/tests](https://github.com/NixOS/nixpkgs/blob/master/lib/tests) or [pkgs/test](https://github.com/NixOS/nixpkgs/blob/master/pkgs/test)
- made sure NixOS tests are [linked](https://nixos.org/manual/nixpkgs/unstable/#ssec-nixos-tests-linking) to the relevant packages
- [ ] Tested compilation of all packages that depend on this change using `nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"`. Note: all changes have to be committed, also see [nixpkgs-review usage](https://github.com/Mic92/nixpkgs-review#usage)
- [ ] Tested basic functionality of all binary files (usually in `./result/bin/`)
- [24.05 Release Notes](https://github.com/NixOS/nixpkgs/blob/master/nixos/doc/manual/release-notes/rl-2405.section.md) (or backporting [23.05](https://github.com/NixOS/nixpkgs/blob/master/nixos/doc/manual/release-notes/rl-2305.section.md) and [23.11](https://github.com/NixOS/nixpkgs/blob/master/nixos/doc/manual/release-notes/rl-2311.section.md) Release notes)
- [ ] (Package updates) Added a release notes entry if the change is major or breaking
- [ ] (Module updates) Added a release notes entry if the change is significant
- [ ] (Module addition) Added a release notes entry if adding a new NixOS module
- [x] Fits [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
---
Add a :+1: [reaction] to [pull requests you find important].
[reaction]: https://github.blog/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/
[pull requests you find important]: https://github.com/NixOS/nixpkgs/pulls?q=is%3Aopen+sort%3Areactions-%2B1-desc
1 Like
Thanks for the explanation. Now I get it.