Need help? Createn an issue or ping @Gytis#0001 in discord server above.
This flake exposes a library abstraction to painlessly generate nixos flake configurations.
The biggest design goal is to keep down the fluff. The library is meant to be easy to understand and use. It aims to be far simpler than frameworks such as devos (previously called nixflk).
This flake provides two main features (visible from flake.nix):
nixosModules.saneFlakeDefaults- Configuresnix.*attributes. Generatesnix.nixPath/nix.registryfrom flakeinputs, setspkgs.nixUnstableas the default also enablesca-referencesandflakes.lib.systemFlake { ... }- Generates a system flake that may then be built.lib.exporter.modulesFromListExporter [ ./a.nix ./b.nix ]- Generates modules attributes which looks like this{ a = import ./a.nix; b = import ./b.nix; }.lib.exporter.overlaysFromChannelsExporter channels- Collects all overlays from channels and exports them as an appropriately namespaced attribute set. Users can instantiate with their nixpkgs version.lib.builder.packagesFromOverlayBuilderConstructor channels pkgs- Similar to the overlay generator, but outputs them as packages, instead. Users can use your cache.
Example flake with all available attributes can be found Here. (WARNING: Quite overwhelming)
And more realistic flake example can be found Here.
I strongly recommend referring to actual people examples above when setting up your system.
Looking to add a kick-ass repl to your config? Create and import something along the lines of this:
{ inputs, ... }:
{
environment.shellAliases = {
very-cool-nix-repl = "nix repl ${inputs.utils.lib.repl}";
};
}let
inherit (builtins) removeAttrs;
mkApp = utils.lib.mkApp;
# If there is a need to get direct reference to nixpkgs - do this:
pkgs = self.pkgs.x86_64-linux.nixpkgs;
in flake-utils-plus.lib.systemFlake {
# `self` and `inputs` arguments are REQUIRED!!!!!!!!!!!!!!
inherit self inputs;
# Supported systems, used for packages, apps, devShell and multiple other definitions. Defaults to `flake-utils.lib.defaultSystems`.
supportedSystems = [ "x86_64-linux" ];
################
### channels ###
################
# Configuration that is shared between all channels.
channelsConfig = { allowBroken = true; };
# Overlays which are applied to all channels.
sharedOverlays = [ nur.overlay ];
# Nixpkgs flake reference to be used in the configuration.
channels.<name>.input = nixpkgs;
# Channel specific config options.
channels.<name>.config = { allowUnfree = true; };
# Patches to apply on selected channel.
channels.<name>.patches = [ ./someAwesomePatch.patch ];
# Overlays to apply on a selected channel.
channels.<name>.overlaysBuilder = channels: [
(final: prev: { inherit (channels.unstable) neovim; })
];
####################
### hostDefaults ###
####################
# Default architecture to be used for `hosts` defaults to "x86_64-linux".
hostDefaults.system = "x86_64-linux";
# Default modules to be passed to all hosts.
hostDefaults.modules = [ utils.nixosModules.saneFlakeDefaults ];
# Reference to `channels.<name>.*`, defines default channel to be used by hosts. Defaults to "nixpkgs".
hostDefaults.channelName = "unstable";
# Extra arguments to be passed to all modules. Merged with host's extraArgs.
hostDefaults.extraArgs = { inherit utils inputs; foo = "foo"; };
#############
### hosts ###
#############
# System architecture. Defaults to `defaultSystem` argument.
hosts.<hostname>.system = "aarch64-linux";
# <name> of the channel to be used. Defaults to `nixpkgs`;
hosts.<hostname>.channelName = "unstable";
# Extra arguments to be passed to the modules.
hosts.<hostname>.extraArgs = { abc = 123; };
# These are not part of the module system, so they can be used in `imports` lines without infinite recursion.
hosts.<hostname>.specialArgs = { thing = "abc"; };
# Host specific configuration.
hosts.<hostname>.modules = [ ./configuration.nix ];
# Flake output for configuration to be passed to. Defaults to `nixosConfigurations`.
hosts.<hostname>.output = "darwinConfigurations";
# System builder. Defaults to `channels.<name>.input.lib.nixosSystem`.
# `removeAttrs` workaround due to this issue https://github.com/LnL7/nix-darwin/issues/319
hosts.<hostname>.builder = args: nix-darwin.lib.darwinSystem (removeAttrs args [ "system" ]);
#############################
### flake output builders ###
#############################
# Evaluates to `packages.<system>.coreutils = <unstable-channel-reference>.coreutils`.
packagesBuilder = channels: { inherit (channels.unstable) coreutils; };
# Evaluates to `defaultPackage.<system>.neovim = <nixpkgs-channel-reference>.neovim`.
defaultPackageBuilder = channels: channels.nixpkgs.neovim;
# Evaluates to `apps.<system>.custom-neovim = utils.lib.mkApp { drv = ...; exePath = ...; };`.
appsBuilder = channels: with channels.nixpkgs; {
custom-neovim = mkApp {
drv = fancy-neovim;
exePath = "/bin/nvim";
};
};
# Evaluates to `apps.<system>.firefox = utils.lib.mkApp { drv = ...; };`.
defaultAppBuilder = channels: mkApp { drv = channels.nixpkgs.firefox; };
# Evaluates to `devShell.<system> = <nixpkgs-channel-reference>.mkShell { name = "devShell"; };`.
devShellBuilder = channels: channels.nixpkgs.mkShell { name = "devShell"; };
#########################################################
### All other properties are passed down to the flake ###
#########################################################
checks.x86_64-linux.someCheck = pkgs.hello;
packages.x86_64-linux.somePackage = pkss.hello;
overlay = import ./overlays;
abc = 132;
}