Comments (9)
You can override pkgs
like so:
{
perSystem = { pkgs, system, ... }: {
_module.args.pkgs = import nixpkgs { inherit system; overlays = [ myOverlay ]; };
};
}
By default it's set to inputs'.nixpkgs.legacyPackages
.
from flake-parts.
It feels a bit hacky yeah, but this is essentially how you define special args in the standard nixos module system. From what I gather, the long term plan is to remove nixpkgs
entirely from the default flake-parts setup (#41) and replace it with an easily configurable nixpkgs
module (#74) that you can import.
from flake-parts.
You can override
pkgs
like so:
Thanks, that was very timely, as we're going through a similar process to @antifuchs.
FYI, we do this sort of thing in nearly all of our flakes, so it would be nice if it were more ergonomic.
from flake-parts.
Thank you very much, @szlend, that is exactly what I was hoping for. Agreed that this would be an excellent thing to allow for a customization, but there are many nixpkgs options people might want to set - privileging overlays like that might make the other options annoying (I am thinking of #105 here, but other options exist too).
from flake-parts.
So the best way to use something like emacs-overlay
in a flake-parts flake would be this (working) flake?
{
description = "Description for the project";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
emacs-overlay.url = "github:nix-community/emacs-overlay";
};
outputs = inputs@{ flake-parts, nixpkgs, emacs-overlay, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [ "x86_64-linux" "aarch64-darwin" ];
perSystem = { config, self', inputs', pkgs, system, ... }: {
_module.args.pkgs = import nixpkgs
{
inherit system;
overlays = [ emacs-overlay.overlays.default ];
};
packages.default = pkgs.emacsGit;
};
flake = { };
};
}
_module.args.pkgs = import nixpkgs
seems hacky and _module
seems like something that's internal. Is that untrue?
from flake-parts.
@szlend Thank you so much for that context, that sounds like a good plan.
from flake-parts.
Just came up against another scenario where I don't quite get how to set the arguments on a flake part: I'm trying to define dockerContainers
, and so (AIUI) I need to use withSystem
, as they're not supported by perSystem
.
My flake part defining these docker containers does the following:
{
self,
lib,
pkgs',
inputs,
withSystem,
...
}: {
flake.dockerContainers.boinkornet-monitor = withSystem "x86_64-linux" ({pkgs, ...}: pkgs.callPackage ./monitor {});
flake.dockerContainers.boinkornet-media-forwarder = withSystem "x86_64-linux" ({pkgs, ...}: pkgs.callPackage ./media-forwarder {});
}
And the monitor/default.nix calls dockerTools.buildLayeredImage
; I'd like the withSystem's pkgs
argument to be augmented with overlays, but I don't quite see where to put the _module.args.pkgs
in this scheme such that flake.parts can define the container with the right pkgs definition.
Update: The trick seems to be to use perSystem
in my flake part and set a different argument (pkgs
is already getting overridden with overlays in another part, and setting that leads to an infinite recursion). The following seems to work:
{
self,
lib,
pkgs',
inputs,
withSystem,
...
}: {
perSystem = {
config,
system,
self',
inputs',
pkgs,
...
}: {
_module.args = {
finalPkgs = import inputs.nixpkgs-linux {
inherit system;
overlays = [
self.overlays.default # Pulls in the overlay defined by this flake
];
};
};
};
flake.dockerContainers.boinkornet-monitor = withSystem "x86_64-linux" ({finalPkgs, ...}: finalPkgs.callPackage ./monitor {}); # Uses the packages augmented with our flake's overlay
flake.dockerContainers.boinkornet-media-forwarder = withSystem "x86_64-linux" ({pkgs, ...}: pkgs.callPackage ./media-forwarder {});
}
from flake-parts.
Hi, could someone help me, how to use easyOverlay with _module.args.pkgs?
from flake-parts.
perSystem = { config, self', inputs', pkgs, system, lib, devenv, ... }: {
_module.args = {
pkgs = import nixpkgs {
inherit system;
# For ssm-session-manager-plugin
config.allowUnfree = true;
overlays = [
(_: _: {
inherit (config.packages) neovim-nightly vcluster kubeswitch yamlfmt comic-code flypie;
})
];
};
};
devenv.shells.default = {
languages.nix.enable = true;
};
packages = with pkgs; {
neovim-nightly = neovim.packages.${system}.neovim;
vcluster = callPackage ./pkgs/vcluster { };
kubeswitch = callPackage ./pkgs/kubeswitch { };
yamlfmt = callPackage ./pkgs/yamlfmt { };
comic-code = callPackage ./pkgs/comic-code { };
flypie = callPackage ./pkgs/flypie { };
};
overlayAttrs = {
inherit (config.packages) neovim-nightly vcluster kubeswitch yamlfmt comic-code flypie;
};
};
This is what I have so far. It's working but I like to do something like this:
_module.args = {
pkgs = import nixpkgs {
inherit system;
# For ssm-session-manager-plugin
config.allowUnfree = true;
overlays = [ config.flake.overlays.default ];
};
};
overlayAttrs = {
inherit (config.packages) neovim-nightly vcluster kubeswitch yamlfmt comic-code flypie;
};
But it will generate error config.flake
is not available.
from flake-parts.
Related Issues (20)
- pre-commit.devShell usage? HOT 1
- Template flakes do not contain `flake-parts` as input, yet they rely on it. HOT 1
- How to configure multiple overlays to different hosts? HOT 3
- Segmentation fault during flake evaluation using overlayAttrs HOT 7
- Better naming `mkPerSystemOption` HOT 4
- Documenting naming conventions HOT 4
- Cannot access `inputs.self.outPath` in top level `imports` HOT 4
- Make `self'/self` and `inputs'/inputs` more similar HOT 1
- `flake.flakeModules` requirements HOT 4
- `bundlers` output
- perSystem is too eager by default
- how to share a library without using an overlay HOT 2
- Separate flake for nixpkgs dependency HOT 1
- Would an example folder be welcome? HOT 3
- Provide a way to easily run doc tests HOT 1
- Explicitly pass default nixpkgs to mkFlake
- Document, how to declare packages only for concrete system
- perSystem.packages cannot be used with recursive packages HOT 1
- NixOS options not 1:1 available HOT 2
- nixosConfigurations example does not invoke nixosConfigurations HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flake-parts.