-
Notifications
You must be signed in to change notification settings - Fork 108
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
API Discussions #232
API Discussions #232
Changes from all commits
141efa9
f1ed2de
7b93e33
68927e1
4f69777
7153c92
0f656a8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
# DevOS 2.0 | ||
|
||
- We want to be a good ecosystem citizen, therefore we want to rebase on [`gytis/flake-utils-plus`](https://github.com/gytis-ivaskevicius/flake-utils-plus). | ||
- `gytis/flake-utils-plus` is designed to be incorporated in upstream flake-utils. As the name suggests, it wraps and extends `flake-utils` for nixos related use cases. | ||
- `devos-lib` shall be another layer that wraps `flakes-utils-plus` and adds accoustomed devos amentities, such as: | ||
- automagic importers, for pure convenience, but without prescribing a particular folder layout (that is something for devos templates to achieve). | ||
- additional configuration generators, such as for `deploy-rs` or `home-manager` or other future integrations (eg. mobile nixos, etc) that we want to offer as a convenience. | ||
- other amentities (tbd) | ||
|
||
|
||
|
||
## Importers | ||
|
||
Importers declutter the top level flake. The goal is to have a bunch of lines that read like a very clean table of contents: | ||
|
||
```nix | ||
concept1 = ./concept1; | ||
concept2 = ./concept2; | ||
concept3 = { "..." = "..."; }; | ||
concept4 = []; | ||
``` | ||
Comment on lines
+16
to
+21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not exactly relevant but having all attributes interpreted like so would be pretty cool: {
concept1 = ./some/directory; # Evaluates to 'concept1 = { fileNameWithoutNixExtension = {...}; }'
concept2 = ./someFile.nix; # Evaluates to 'concept2 = { "..." = "..."; }'
concept3 = { "..." = "..."; }; # Evaluates to 'concept3 = { "..." = "..."; }'
concept4 = []; # Evaluates to 'concept4 = []'
} |
||
It seems important to enable dual use (importing files or declaring inline), in order to allow people to generate user | ||
flakes that put emphasis on different aspects of using devos lib (by sheer looking on the folder hierarchy). | ||
|
||
Some context about importers, and how we might want them to behave: | ||
|
||
- https://github.com/gytis-ivaskevicius/flake-utils-plus/issues/8 | ||
- https://github.com/blaggacao/devos/blob/5d80663bcd3f65cc95fd965b49becc7b24ebf9d4/lib/devos/importer.nix | ||
|
||
|
||
## Config Generators | ||
|
||
Configuration Generators generate configurations for particular entities. In practice and for now, | ||
|
||
- a [nixosConfigurationsGenerator](https://github.com/gytis-ivaskevicius/flake-utils-plus/blob/51cb739c9c9c2258bc70747eb7bc22975ae244bd/systemFlake.nix#L61-L64) creates nixosConfigurations, | ||
- based on which a [deployConfigurationsGenerator](https://github.com/blaggacao/devos/blob/5d80663bcd3f65cc95fd965b49becc7b24ebf9d4/lib/devos/configGenerators.nix#L14-L25) generates deploy-rs configurations & | ||
- a [hmConfigurationsGenerator](https://github.com/blaggacao/devos/blob/5d80663bcd3f65cc95fd965b49becc7b24ebf9d4/lib/devos/configGenerators.nix#L34-L45) generates home manager configurations. | ||
|
||
See also: https://github.com/gytis-ivaskevicius/flake-utils-plus/issues/10 | ||
|
||
|
||
## API | ||
|
||
The devos-lib onion: | ||
|
||
- `builtins` | ||
- `numtide/flake-utils` | ||
- `gytis/flake-utils-plus` | ||
- `divnix/devos` (the lib) | ||
|
||
While flake-utils-plus exports a generic [`utils.systemFlake`](https://github.com/gytis-ivaskevicius/flake-utils-plus/blob/51cb739c9c9c2258bc70747eb7bc22975ae244bd/flake.nix#L37) user function | ||
and is restricted from including dependencies, devos-lib should export a `devos.systemFlake` without such restrictions and that can include | ||
additional (eventually third-party mediated) generatros, such as `deploy-rs`, while implementing a strict superset of | ||
`utils.systemFlake` api and, on the other hand, a `devos.mkFlake` with importer amenities included and a slightly different api for convenience. | ||
|
||
### `devos.systemFlake` | ||
|
||
```nix | ||
# devos.systemFlake | ||
{ | ||
# adopt flake-utils-plus, file upstream issues where discussion is needed | ||
self | ||
, defaultSystem ? "x86_64-linux" | ||
, supportedSystems ? flake-utils.lib.defaultSystems | ||
, name # or inputs, see: https://github.com/gytis-ivaskevicius/flake-utils-plus/issues/12 | ||
, nixosHosts ? { NAME = { # https://github.com/gytis-ivaskevicius/flake-utils-plus/issues/16 | ||
system = "..."; | ||
channelName = "..."; | ||
extraArgs = { }; | ||
modules = [ ]; | ||
};} | ||
, channels ? { | ||
input = "..."; | ||
overlaysBuilder = channels: [ (final: prev: { })]; | ||
config = { }; | ||
patches = [ ]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At this point I'm like "can we just pay some C++ nerd to properly implement channels patching as part of Nix binary instead" :D There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, actually that seems like a good venue. We could start by lobbying more heavily and probably Ma29 could lend us a hand. x-ref NixOS/nix#3920 |
||
} | ||
, channelsConfig ? { } | ||
, sharedModules ? [ ] | ||
, sharedOverlays ? [ ] | ||
, nixosSpecialArgs ? { } # https://github.com/gytis-ivaskevicius/flake-utils-plus/issues/13#issuecomment-814512835 | ||
|
||
, hmConfigurations ? { } | ||
, hmProfiles ? { NAME = { | ||
modules = [ ]; | ||
extraArgs = { }; | ||
# what else makes sense, here? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe |
||
};} | ||
|
||
, deployConfigurations ? { } | ||
|
||
, ... # passed through / https://github.com/gytis-ivaskevicius/flake-utils-plus/issues/14} | ||
``` | ||
|
||
### `devos.mkFlake` | ||
|
||
This is all about importer amentities over `devos.systemFlake`. | ||
|
||
For example people should be able to define either paths or functions as arguments. | ||
Also we might consider special (import !only!) magic like reducing: | ||
|
||
```nix | ||
{ | ||
nixos = { | ||
modules = ./modules; | ||
profiles = ./profiles; | ||
specialArgs = { }; # https://github.com/gytis-ivaskevicius/flake-utils-plus/issues/13#issuecomment-814512835 | ||
hosts = ./hosts; | ||
suites = ./suites; | ||
}; | ||
} | ||
``` | ||
|
||
to | ||
|
||
```nix | ||
{ | ||
nixos = ./os; # with default fallback folder naming scheme | ||
} | ||
``` | ||
|
||
#### Part 1: Passthrough API from `devos.systemFlake` | ||
|
||
We should not change the api here, but rather seek upstream amendmend. | ||
```nix | ||
# devos.mkFlake | ||
{ | ||
self | ||
, defaultSystem ? "x86_64-linux" | ||
, supportedSystems ? flake-utils.lib.defaultSystems | ||
, name # or inputs, see: https://github.com/gytis-ivaskevicius/flake-utils-plus/issues/12 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If namespacing is no longer a goal, name isn't necessary. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it boils down to how foreign flakes should be consumed. So it's kind of a difficult normative call to make. As I argue in the linked issue, |
||
, channels ? { | ||
input = "..."; | ||
overlaysBuilder = channels: [ (final: prev: { })]; # TODO: do we want another interface here? Also: how to handle module backports? | ||
config = { }; | ||
patches = [ ]; | ||
} | ||
, channelsConfig ? { } | ||
# TODO: two dimensions: | ||
# - shared vs. "per-host" | ||
# - external (consuming other devos flakes) vs internal | ||
, sharedModules ? [ ] | ||
, sharedOverlays ? [ ] | ||
Comment on lines
+142
to
+143
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would say call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In theory, we have:
... in theory. We have to make a good cut, I guess. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sharedOverlays vs overlays - calling it internalModules - I'd say naming could be better than that. Maybe something that actually represents that its auto imported to all the configurations? Overall, I'm quite a fan of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FWIW |
||
, ... # passed through | ||
} | ||
``` | ||
|
||
#### Part 2: Devos NixOS/hm/... configuration API | ||
```nix | ||
# devos.mkFlake | ||
{ | ||
# allow setting those in a variety of (polished ways) | ||
# like suites = { one = {}; two = {};}; instead of ./suites | ||
, nixos ? { | ||
modules = ./modules; | ||
profiles = ./profiles; | ||
specialArgs = { }; # https://github.com/gytis-ivaskevicius/flake-utils-plus/issues/13#issuecomment-814512835 | ||
hosts = ./hosts; | ||
suites = ./suites; | ||
, hm ? { | ||
modules = ./users/modules; | ||
profiles = ./users/profiles; | ||
specialArgs = { }; | ||
suites = ./users/suites; | ||
} | ||
Comment on lines
+154
to
+165
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The idea here is to take those values at face value & in a first step applying maybeImporters and only in a second step function instantiators, the latter passing all nescessary args around. Does that make sense or did I misread your comment? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mean the way default values are implemented - if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah! @Pacman99 in the meanwhile is an expert of validating, crosschecking and defaulting values via the module system. I think it will be a mix of a:
|
||
} | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would be so down with implementing deploy-rs and HM as part of the flake-utils-plus ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At least deploy-rs currently has a dependency injected of a
deploy.lib
library function, though.I still regard being dependency-free as a feature. 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh yeah, I am planning to keep
fup
dependency-free :)