Skip to content
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

Release 1.2.0 #46

Merged
merged 106 commits into from
Sep 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
9b9145e
update flake-utils for filterPackages fixups
Apr 25, 2021
7418d2c
imp: provide per channel modules paths to make it easy to "backport"
Apr 22, 2021
4eb7af8
fix test
Apr 25, 2021
f6c13a7
overlays exporter: use pkgs and inputs
Apr 25, 2021
052909f
packagesBuilder constructor: take set of overlays
Apr 25, 2021
e3ba667
examples: demonstrate updated exporters/builders
Apr 25, 2021
addbb12
Merge pull request #43 from Pacman99/cleanup-exporters
Pacman99 Apr 25, 2021
4439748
pass channel to hosts as channel specialArg
Apr 25, 2021
1245b7e
fix Rick host build by making it separate
Apr 26, 2021
0f0c148
Merge pull request #44 from Pacman99/channel-specialArg
Pacman99 Apr 26, 2021
b608376
add simple devshell & align dev and ci environment
Apr 16, 2021
80b53ee
fixups / cleanups devshell
Apr 20, 2021
be032a4
prevent infinite recursion in overlays exporter
Apr 26, 2021
8eb7f92
export mergeAny in public lib
Apr 27, 2021
7c085ed
Add 'srcs' to overlays
gytis-ivaskevicius Apr 27, 2021
1d2be73
Add ability to create non-exported overlays
Apr 28, 2021
0642ac5
Merge pull request #50 from Pacman99/dontexport-overlay
Pacman99 Apr 29, 2021
1630b59
always use self.pkgs instead of channels
May 2, 2021
f325752
set __dontExport to srcs overlay
May 2, 2021
3c4ea74
Merge pull request #52 from Pacman99/prefer-self-pkgs
Pacman99 May 3, 2021
c7eb689
Merge pull request #53 from Pacman99/dontexport-srcs
Pacman99 May 3, 2021
1a74204
flake: update flake-utils input
May 12, 2021
f4d0536
Work on tests and restructoring (#54)
gytis-ivaskevicius May 15, 2021
e027842
fromOverlays: opt-in for exporting sub-systems
Pacman99 May 17, 2021
3c6efcb
Add replace xyzBuilder with unified 'outputsBuilder'
gytis-ivaskevicius May 17, 2021
6bdff31
Add derivation tests
gytis-ivaskevicius May 17, 2021
78f7c9b
Tests cleanup
gytis-ivaskevicius May 19, 2021
1efba19
Add build-all and check-all commands
gytis-ivaskevicius May 19, 2021
c7ba2eb
Merge pull request #59 from gytis-ivaskevicius/add-outputs-builder
gytis-ivaskevicius May 19, 2021
8d8f9d7
modulesFromList: allow for import customization
Pacman99 May 21, 2021
3929c2b
Merge pull request #65 from Pacman99/modulesFromList-improvements
gytis-ivaskevicius May 21, 2021
19dc794
Rename lib to src
gytis-ivaskevicius May 23, 2021
eb85b66
#60: nixUnstable -> nixFlakes
gytis-ivaskevicius May 23, 2021
12917cb
#63: Replace saneFlakeDefaults with nix.generateRegistryFromInputs op…
gytis-ivaskevicius May 23, 2021
ffd0078
Fix few repl.nix usecases
gytis-ivaskevicius May 23, 2021
9cda359
#61: Implement 'channels.<name>.input' autogen if not defined
gytis-ivaskevicius May 23, 2021
a798645
Revert "#60: nixUnstable -> nixFlakes"
fufexan May 24, 2021
42a645c
Merge pull request #68 from fufexan/staging
gytis-ivaskevicius May 24, 2021
dc620d9
Merge branch 'staging' of github.com:gytis-ivaskevicius/flake-utils-p…
gytis-ivaskevicius May 25, 2021
74e38e6
Fix nix.extraOptions
gytis-ivaskevicius May 27, 2021
5d36f03
Work on repl.nix
gytis-ivaskevicius May 23, 2021
872d8c3
Add fup-repl
gytis-ivaskevicius May 23, 2021
e405eb9
Merge pull request #66 from gytis-ivaskevicius/various-fixes
gytis-ivaskevicius May 27, 2021
d526007
Add support for reverse DNS hostname declarations
May 27, 2021
ae2bb10
fix: if domain is not set, pass a default only to remain overridable.
May 28, 2021
4ee8645
fix/style: pull used builtins in scope
May 31, 2021
9e93efb
fix: naming
May 31, 2021
7f23711
fixup
May 31, 2021
1009687
don't append overlays manually when passing pkgs
Pacman99 Jun 1, 2021
247c99f
systemFlake: set __dontExport for fupOverlay
Pacman99 Jun 1, 2021
6b2ea4b
Update testing-utils.nix derivation names
gytis-ivaskevicius Jun 1, 2021
38f0103
bump flake-utils: incorporate new shiny check-utils
Jun 14, 2021
cfe0181
Revert "modulesFromList: allow for import customization"
Jun 15, 2021
e9cfad7
modulesFromList: infer names from paths or modules's _file attr
Jun 15, 2021
785e6f1
fixup! modulesFromList: infer names from paths or modules's _file attr
blaggacao Jun 19, 2021
36d9cd2
Update dependencies + implement check-utils
gytis-ivaskevicius Jun 20, 2021
f60eb46
Seperate repl overlay and implement help menu
gytis-ivaskevicius Jun 20, 2021
b87458d
Make repl find system flake path more dynamically
gytis-ivaskevicius Jun 20, 2021
68983c1
Make 'self' flake to always exist as part of the registry
gytis-ivaskevicius Jun 20, 2021
91cad97
Fix repl paths checking
gytis-ivaskevicius Jun 20, 2021
5f0106f
Merge pull request #73 from gytis-ivaskevicius/#62
gytis-ivaskevicius Jun 25, 2021
490c38a
Allow repl open even if flake was not found
gytis-ivaskevicius Jun 25, 2021
5cf2e3e
71: Fix repl reproducability
gytis-ivaskevicius Jun 25, 2021
438316a
Add loadFlake function
gytis-ivaskevicius Jun 25, 2021
6bf0d31
Merge pull request #74 from gytis-ivaskevicius/repl-improvements
gytis-ivaskevicius Jun 26, 2021
0a8e400
Add mkDefault to extra-options
gytis-ivaskevicius Jul 3, 2021
f0cbd4d
Use extra-experimental-features instead of experimental-features
gytis-ivaskevicius Jul 9, 2021
c94a68e
Fix formatting
gytis-ivaskevicius Jul 9, 2021
d6bbc2e
Merge pull request #78 from gytis-ivaskevicius/experimental-features
gytis-ivaskevicius Jul 9, 2021
d490fe9
examples: add comments
fufexan Jul 11, 2021
96d816c
imp: allow arguments for devshell checks
blaggacao Jul 14, 2021
5c6ee69
imp: make output dynamic according to outputsBuilder
blaggacao Jul 12, 2021
2e5c29d
README: update documentation to future lib
fufexan Jul 11, 2021
55d7473
Update README.md
gytis-ivaskevicius Jul 16, 2021
354653d
Merge pull request #81 from fufexan/docs
gytis-ivaskevicius Jul 16, 2021
0bd2448
Fix Github Actions
gytis-ivaskevicius Jul 14, 2021
90c45a9
Fix build scripts
gytis-ivaskevicius Jul 18, 2021
05478f0
Post rebase fixes
gytis-ivaskevicius Jul 18, 2021
be7b628
Post rebase fixes
gytis-ivaskevicius Jul 18, 2021
10b5a33
Merge pull request #83 from gytis-ivaskevicius/github-actions
gytis-ivaskevicius Jul 18, 2021
1675f46
move functions to lib/internal-functions.nix
fufexan Jul 14, 2021
f53affe
flake.nix: change functions to new names
fufexan Jul 17, 2021
a9c80ba
flake.nix: move internal-functions to own attrset
fufexan Jul 19, 2021
d5cd10d
properly call internal lib
fufexan Jul 19, 2021
22256e8
fix formatting
fufexan Jul 19, 2021
0f7b216
rename export{Overlays,Packages}
fufexan Jul 20, 2021
5dba755
Merge pull request #84 from fufexan/exporters
fufexan Jul 20, 2021
ea46e02
fix: exportModules can be a function or attrs
blaggacao Jul 20, 2021
51a8292
fix: reverse rakeLeaves implementation for exportModules
blaggacao Jul 23, 2021
a79a0b8
Fix modulesFromList deprecation
gytis-ivaskevicius Aug 13, 2021
3d108c9
Update devshell
gytis-ivaskevicius Aug 22, 2021
6a7b7ff
Update flake-utils
gytis-ivaskevicius Aug 22, 2021
ebb4174
Update README.md
gytis-ivaskevicius Aug 23, 2021
ecfd19c
Tweak repl implementation
gytis-ivaskevicius Aug 23, 2021
8a85558
Update README.md
gytis-ivaskevicius Aug 24, 2021
28ad5a2
Update README.md
gytis-ivaskevicius Aug 24, 2021
e1eddbd
Update channels selection filter logic
gytis-ivaskevicius Aug 24, 2021
cb44a3f
Update channels selection filter logic
gytis-ivaskevicius Aug 24, 2021
daab9cb
Remove nix_path option from workflow file
gytis-ivaskevicius Aug 24, 2021
8a307b8
Add NIX_PATH and linkInputs option
gytis-ivaskevicius Sep 5, 2021
fb18a43
Update README with branching policy
gytis-ivaskevicius Sep 5, 2021
d095b5d
Fix missing channel.shortRev when executing tests locally
gytis-ivaskevicius Sep 5, 2021
b4848f5
Fix typo
gytis-ivaskevicius Sep 5, 2021
82ca1c5
Remove deprecated code from examples
gytis-ivaskevicius Sep 5, 2021
a5c54d9
Hint on using tagged releases and explain 1.2.0 vs 1.2.1
blaggacao Sep 5, 2021
ccc1137
fix typo
blaggacao Sep 5, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 17 additions & 33 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,46 +6,30 @@ on:
types: [opened]

jobs:
quality-gate:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.4
- uses: cachix/install-nix-action@v13
with:
nix_path: nixpkgs=channel:nixos-unstable
install_url: https://github.com/numtide/nix-flakes-installer/releases/download/nix-3.0pre20201007_5257a25/install
install_url: https://github.com/numtide/nix-unstable-installer/releases/download/nix-2.4pre20210604_8e6ee1b/install
extra_nix_config: experimental-features = nix-command flakes

- name: Check Nix parsing
run: find . -name "*.nix" -exec nix-instantiate --parse --quiet {} >/dev/null +
# Quick eval
- run: nix develop --command evalnix

- name: Run `nix flake check`
run: cd examples/fully-featured && nix flake check --show-trace
# Execute /tests/*
- run: nix develop --command check-derivation-outputs
- run: nix develop --command check-derivation-outputs-old
- run: nix develop --command check-channel-patching
- run: nix develop --command check-overlays-flow
- run: nix develop --command check-hosts-config

- name: Run `nix flake show`
run: cd examples/fully-featured && nix flake show --show-trace

- name: Build Morty configuration
run: cd examples/fully-featured && nix build .#nixosConfigurations.Morty.config.system.build.toplevel --dry-run

- name: Build Rick configuration
run: cd examples/fully-featured && nix build .#someConfigurations.Rick.config.system.build.toplevel --dry-run

- name: Build Summer checks
run: cd examples/fully-featured && nix build .#checks.x86_64-linux.summerHasUnfreeConfigured && nix build .#checks.x86_64-linux.summerHasPackageOverridesConfigured && nix build .#checks.x86_64-linux.summerHasCustomModuleConfigured

- name: Run `nix flake check`
run: cd examples/somewhat-realistic && nix flake check --show-trace

- name: Run `nix flake show`
run: cd examples/somewhat-realistic && nix flake show --show-trace

- name: Build HostnameOne configuration
run: cd examples/somewhat-realistic && nix build .#nixosConfigurations.HostnameOne.config.system.build.toplevel --dry-run

- name: Check Nix formatting
run: nix shell nixpkgs\#nixpkgs-fmt -c nixpkgs-fmt --check .

- name: Build HostnameThree configuration
run: cd examples/somewhat-realistic && nix build .#darwinConfigurations.HostnameThree.config.system.build.toplevel --dry-run
# Build /examples/*
- run: nix develop --command build-home-manager+nur+neovim-Rick
- run: nix develop --command build-minimal-multichannel-Hostname1
- run: nix develop --command build-minimal-multichannel-Hostname2
- run: nix develop --command build-exporters-Morty

# Check formatting
- run: nix develop --command fmt --check
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
examples/*/flake.lock
examples/*/result
113 changes: 63 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,64 +1,74 @@

[![Discord](https://img.shields.io/discord/591914197219016707.svg?label=&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2)](https://discord.com/invite/RbvHtGa)

Need help? Createn an issue or ping @Gytis#0001 in discord server above.
Need help? Create an issue or ping @Gytis#0001 in the above Discord Server.

# What is this flake #
# Changing branching policy #
From now on `master` serves as a development branch (previously `staging` was used for such purposes). Please use tags for stable releases of flake-utils-plus.
In general, with the improvements in test harness, releases might happen more frequently. Sticking with a tagged release might offer better trade-offs going forward.

This flake exposes a library abstraction to *painlessly* generate nixos flake configurations.
Please note, while 1.2.0 retains backwards compatibility, 1.2.1 is the same version with all backwards compatibility removed.

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).

# Features of flake #
# What is this flake? #

This flake provides two main features (visible from `flake.nix`):
Flake-utils-plus exposes a library abstraction to *painlessly* generate NixOS flake configurations.

- `nixosModules.saneFlakeDefaults` - Configures `nix.*` attributes. Generates `nix.nixPath`/`nix.registry` from flake `inputs`, sets `pkgs.nixUnstable` as the default also enables `ca-references` and `flakes`.
- `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.
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).

# Features of the flake #

# Examples #
Main flake-utils-plus features (Attributes visible from `flake.nix`):
- Extends [flake-utils](https://github.com/numtide/flake-utils). Everything exported by fu can be used from this flake.
- `lib.mkFlake { ... }` - Clean and pleasant to use flakes abstraction.
- Option [`nix.generateRegistryFromInputs`](./lib/options.nix) - Generates `nix.registry` from flake inputs.
- Option [`nix.generateNixPathFromInputs`](./lib/options.nix) - Generate `nix.nixPath` from available inputs.
- Option [`nix.linkInputs`](./lib/options.nix) - Symlink inputs to /etc/nix/inputs.
- Simple and clean support for multiple `nixpkgs` references.
- `nixpkgs` references patching.
- `channelsConfig` - Config applied to all `nixpkgs` references.
- `hostDefaults` - Default configuration shared between host definitions.
- `outputsBuilder` - Clean way to export packages/apps/etc.
- `sharedOverlays` - Overlays applied on all imported channels.
- [`lib.exportModules [ ./a.nix ./b.nix ]`](./lib/exportModules.nix) - Generates module attribute which look like this `{ a = import ./a.nix; b = import ./b.nix; }`.
- [`lib.exportOverlays channels`](./lib/exportOverlays.nix) - Exports all overlays from channels as an appropriately namespaced attribute set. Users can instantiate with their nixpkgs version.
- [`lib.exportPackages self.overlays channels`](./lib/exportPackages.nix) - Similar to the overlay generator, but outputs them as packages for the platforms defined in `meta.platforms`. Unlike overlays, these packages are consistent across flakes allowing them to be cached.
- [`pkgs.fup-repl`](./lib/overlay.nix) - A package that adds a kick-ass repl. Usage:
- `$ repl` - Loads your system repl into scope as well as `pkgs` and `lib` from `nixpkgs` input.
- `$ repl /path/to/flake.nix` - Same as above but loads the specified flake.

- [Gytis Dotfiles (Author of this project)](https://github.com/gytis-ivaskevicius/nixfiles/blob/master/flake.nix)
- [Fufexan Dotfiles](https://github.com/fufexan/dotfiles/blob/main/flake.nix)
- [Bobbbay Dotfiles](https://github.com/Bobbbay/dotfiles/blob/master/flake.nix)
- [Charlotte Dotfiles](https://github.com/chvp/nixos-config/blob/master/flake.nix)
# How to use #

# How to use this flake #
* [Example of using multiple channels](./examples/minimal-multichannel)

Example flake with all available attributes can be found [Here](https://github.com/gytis-ivaskevicius/flake-utils-plus/blob/master/examples/fully-featured/flake.nix). (WARNING: Quite overwhelming)
* [Exporters usage example](./examples/exporters)

And more realistic flake example can be found [Here](https://github.com/gytis-ivaskevicius/flake-utils-plus/blob/master/examples/somewhat-realistic/flake.nix).
* [Using FUP to configure hosts with Home Manager, NUR and neovim](./examples/home-manager+nur+neovim)

I strongly recommend referring to actual people examples above when setting up your system.
## Examples

Looking to add a kick-ass repl to your config? Create and import something along the lines of this:
```nix
{ inputs, ... }:
We recommend referring to people's examples below when setting up your system.

{
environment.shellAliases = {
very-cool-nix-repl = "nix repl ${inputs.utils.lib.repl}";
};
}
- [Gytis Dotfiles (Author of this project)](https://github.com/gytis-ivaskevicius/nixfiles/blob/master/flake.nix)
- [Fufexan Dotfiles](https://github.com/fufexan/dotfiles/blob/main/flake.nix)
- [Bobbbay Dotfiles](https://github.com/Bobbbay/dotfiles/blob/master/flake.nix)
- [Charlotte Dotfiles](https://github.com/chvp/nixos-config/blob/master/flake.nix)

```

## Documentation as code. Options with their example usage and description.
# Documentation

Options with their example usage and description.

```nix
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 {
in flake-utils-plus.lib.mkFlake {


# `self` and `inputs` arguments are REQUIRED!!!!!!!!!!!!!!
# `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`.
Expand All @@ -76,6 +86,7 @@ in flake-utils-plus.lib.systemFlake {
sharedOverlays = [ nur.overlay ];

# Nixpkgs flake reference to be used in the configuration.
# Autogenerated from `inputs` by default.
channels.<name>.input = nixpkgs;

# Channel specific config options.
Expand All @@ -98,7 +109,7 @@ in flake-utils-plus.lib.systemFlake {
hostDefaults.system = "x86_64-linux";

# Default modules to be passed to all hosts.
hostDefaults.modules = [ utils.nixosModules.saneFlakeDefaults ];
hostDefaults.modules = [ ./module.nix ./module2 ];

# Reference to `channels.<name>.*`, defines default channel to be used by hosts. Defaults to "nixpkgs".
hostDefaults.channelName = "unstable";
Expand Down Expand Up @@ -135,28 +146,31 @@ in flake-utils-plus.lib.systemFlake {


#############################
### flake output builders ###
### flake outputs builder ###
#############################

# 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";
outputsBuilder = channels: {
# Evaluates to `apps.<system>.custom-neovim = utils.lib.mkApp { drv = ...; exePath = ...; };`.
apps = {
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 `packages.<system>.coreutils = <unstable-nixpkgs-reference>.package-from-overlays`.
packages = { inherit (channels.unstable) package-from-overlays; };

# Evaluates to `devShell.<system> = <nixpkgs-channel-reference>.mkShell { name = "devShell"; };`.
devShellBuilder = channels: channels.nixpkgs.mkShell { name = "devShell"; };
# Evaluates to `apps.<system>.firefox = utils.lib.mkApp { drv = ...; };`.
defaultApp = mkApp { drv = channels.nixpkgs.firefox };

# Evaluates to `defaultPackage.<system>.neovim = <nixpkgs-channel-reference>.neovim`.
defaultPackage = channels.nixpkgs.neovim;

# Evaluates to `devShell.<system> = <nixpkgs-channel-reference>.mkShell { name = "devShell"; };`.
devShell = channels.nixpkgs.mkShell { name = "devShell"; };
};


#########################################################
Expand All @@ -170,4 +184,3 @@ in flake-utils-plus.lib.systemFlake {

}
```

86 changes: 86 additions & 0 deletions devShell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
{ system ? builtins.currentSystem }:
let
# nixpkgs / devshell is only used for development. Don't add it to the flake.lock.
nixpkgsGitRev = "82d05e980543e1703cbfd3b5ccd1fdcd4b0f1f00";
devshellGitRev = "26f25a12265f030917358a9632cd600b51af1d97";

nixpkgsSrc = fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/${nixpkgsGitRev}.tar.gz";
sha256 = "02yqgivv8kxksv7n6vmh22qxprlfjh4rfkgf98w46nssq5ahdb1q";
};

devshellSrc = fetchTarball {
url = "https://github.com/numtide/devshell/archive/${devshellGitRev}.tar.gz";
sha256 = "sha256:0f6fph5gahm2bmzd399mba6b0h6wp6i1v3gryfmgwp0as7mwqpj7";
};

pkgs = import nixpkgsSrc { inherit system; };
devshell = import devshellSrc { inherit system pkgs; };

withCategory = category: attrset: attrset // { inherit category; };
util = withCategory "utils";

test = name: withCategory "tests" {
name = "check-${name}";
help = "Checks ${name} testcases";
command = ''
set -e
echo -e "\n\n##### Building ${name}\n"
cd $DEVSHELL_ROOT/tests/${name}
nix flake show --no-write-lock-file "$@"
nix flake check --no-write-lock-file "$@"
'';
};

dry-nixos-build = example: host: withCategory "dry-build" {
name = "build-${example}-${host}";
command = ''
set -e
echo -e "\n\n##### Building ${example}-${host}\n"
cd $DEVSHELL_ROOT/examples/${example}
nix flake show --no-write-lock-file "$@"
nix build .#nixosConfigurations.${host}.config.system.build.toplevel --no-write-lock-file --no-link "$@"
'';
};

in
devshell.mkShell {
name = "flake-utils-plus";
packages = with pkgs; [
fd
nixpkgs-fmt
];

commands = [
{
command = "git rm --ignore-unmatch -f $DEVSHELL_ROOT/{tests,examples}/*/flake.lock";
help = "Remove all lock files";
name = "rm-locks";
}
{
name = "fmt";
help = "Check Nix formatting";
command = "nixpkgs-fmt \${@} $DEVSHELL_ROOT";
}
{
name = "evalnix";
help = "Check Nix parsing";
command = "fd --extension nix --exec nix-instantiate --parse --quiet {} >/dev/null";
}

(test "channel-patching")
(test "derivation-outputs")
(test "derivation-outputs-old")
(test "hosts-config")
(test "overlays-flow")
(test "all" // { command = "check-channel-patching && check-derivation-outputs && check-derivation-outputs-old && check-hosts-config && check-overlays-flow"; })

(dry-nixos-build "minimal-multichannel" "Hostname1")
(dry-nixos-build "minimal-multichannel" "Hostname2")
(dry-nixos-build "home-manager+nur+neovim" "Rick")
(dry-nixos-build "exporters" "Morty")
(withCategory "dry-build" { name = "build-all"; command = "build-exporters-Morty && build-home-manager+nur+neovim-Rick && build-minimal-multichannel-Hostname1 && build-minimal-multichannel-Hostname2"; })

];

}
49 changes: 49 additions & 0 deletions examples/exporters/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
description = "FUP exporters demo";

inputs = {
nixpkgs.url = github:nixos/nixpkgs/release-21.05;
unstable.url = github:nixos/nixpkgs/nixos-unstable-small;
utils.url = path:../../;
};


outputs = inputs@{ self, nixpkgs, utils, ... }:
let
inherit (utils.lib) exportOverlays exportPackages exportModules;
in
utils.lib.systemFlake {
inherit self inputs;

# Channel specific overlays. Overlays `coreutils` from `unstable` channel.
channels.nixpkgs.overlaysBuilder = channels: [
(final: prev: { inherit (channels.unstable) ranger; })
];

# Propagates to channels.<name>.overlaysBuilder
sharedOverlays = [
self.overlay
];

hosts.Morty.modules = with self.nixosModules; [
Morty
];

nixosModules = exportModules [
./hosts/Morty.nix
];

# export overlays automatically for all packages defined in overlaysBuilder of each channel
overlays = exportOverlays {
inherit (self) pkgs inputs;
};

outputsBuilder = channels: {
# construct packagesBuilder to export all packages defined in overlays
packages = exportPackages self.overlays channels;
};

overlay = import ./overlays;

};
}
3 changes: 3 additions & 0 deletions examples/exporters/overlays/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
final: prev: {
inherit (prev) coreutils;
}
1 change: 0 additions & 1 deletion examples/fully-featured/configurations/Rick.host.nix

This file was deleted.

6 changes: 0 additions & 6 deletions examples/fully-featured/configurations/Summer.host.nix

This file was deleted.

Loading