Closed Guekka closed 2 years ago
Hey!
Just adding them to overlay/default.nix
(if you're using the standard
template) should work.
I'm sorry, but you could please give a small example? I'm not sure if I have to modify the composeManyExtensions
line
For instance, I'm trying to add openAsar to Discord, which is just a boolean to turn on.
For example please show how to use pkgs from unstable with primary stable nixpkgs
So, it appears just pasting my overlay without the self: super
line inside modifications
appears to work
However, I'd like to find a way to put it in a separate file
Sorry for the delay. The idea is that you can add as many overlays as yout want, e.g. import them from a file or declare them directly. Then you just add it to composeManyExtensions
and you should be good to go. Here's a couple exaples:
Just add them to the existing overlay/default.nix
:
{ inputs, ... }:
let
additions = final: _prev: import ../pkgs { pkgs = final; };
modifications = final: prev: {
some-package = prev.some-package.overrideAttrs (oldAttrs: {
something-something = "foo bar";
});
};
in
inputs.nixpkgs.lib.composeManyExtensions [ additions modifications ]
Or to a separate file:
overlays/cool-overlay.nix
:
final: prev: {
some-package = prev.some-package.overrideAttrs (oldAttrs: {
something-something = "foo bar";
});
}
overlays/default.nix
:
{ inputs, ... }:
let
additions = final: _prev: import ../pkgs { pkgs = final; };
modifications = final: prev: { };
cool-overlay = import ./cool-overlay.nix;
in
inputs.nixpkgs.lib.composeManyExtensions [ additions modifications cool-overlay ]
As for a dual nixpkgs (stable+unstable) setup:
In this example I'll add a hello-unstable
and neovim-unstable
that come from nixos-unstable.
flake.nix
{
# ...
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-22.05";
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
};
# Define your systems using stable nixpkgs...
# ...
}
overlays/default.nix
:
{ inputs, ... }:
let
additions = final: _prev: import ../pkgs { pkgs = final; };
modifications = final: prev: { };
unstable-overrides = final: prev:
let pkgs-unstable = inputs.nixpkgs-unstable.legacyPackages.${final.system};
in {
hello-unstable = pkgs-unstable.hello;
neovim-unstable = pkgs-unstable.neovim;
};
in
inputs.nixpkgs.lib.composeManyExtensions [ additions modifications unstable-overrides ]
You should be able to nix build .#hello-unstable
now.
Hope these examples help you folks out!
They did! I was able to get Copilot working with clion. Thanks!
I'd suggest adding these info to the readme
First, thanks for this template. I've almost been able to convert my configuration to flakes. The only thing I'm missing is overlays. I thought just adding them in the overlay folder would be enough, but it looks like it doesn't work?