Merge #276
276: Update core r=blaggacao a=Pacman99 Core is starting to get pretty stale. All the changes in `develop` are pretty stable and I think we should encourage updating to them. As most future updates can be done through [devlib](https://github.com/divnix/devlib), so once you switch to this version of the template. Updating to new changes will be much simpler (ie #91). Co-authored-by: Pacman99 <pachum99@gmail.com> Co-authored-by: Pacman99 <pachum99@myrdd.info> Co-authored-by: David Arnold <dar@xoe.solutions>
This commit is contained in:
commit
4df3d8c2e8
51 changed files with 824 additions and 1365 deletions
|
@ -1,45 +1,42 @@
|
||||||
# External Art
|
# External Art
|
||||||
When you need to use a module, overlay, or pass a value from one of your inputs
|
When you need to use a module, overlay, or pass a value from one of your inputs
|
||||||
to the rest of your NixOS configuration, [extern][extern] is where you do it.
|
to the rest of your NixOS configuration, you can make use of a couple arguments.
|
||||||
|
It is encouraged to add external art directly in your `flake.nix` so the file
|
||||||
|
represents a complete dependency overview of your flake.
|
||||||
|
|
||||||
Modules and overlays are self explanatory, and the `specialArgs` attribute is
|
## Overlays
|
||||||
used to extend the arguments passed to all NixOS modules, allowing for
|
External overlays can directly be added to a channel's `overlays` list.
|
||||||
arbitrary values to be passed from flake inputs to the rest of your
|
|
||||||
configuration.
|
|
||||||
|
|
||||||
## Home Manager
|
|
||||||
There is also an `hmModules` attribute set for pulling home-manager modules in
|
|
||||||
from the outside world:
|
|
||||||
|
|
||||||
### Declare:
|
|
||||||
flake.nix:
|
flake.nix:
|
||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
inputs.doom-emacs.url = "github:vlaci/nix-doom-emacs";
|
channels.nixos.overlays = [ inputs.agenix.overlay ];
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
Upon exporting overlays, these overlays will be automatically filtered out by inspecting the `inputs` argument.
|
||||||
|
|
||||||
extern/default.nix:
|
## Modules
|
||||||
|
There is a dedicated `nixos.hostDefaults.externalModules` argument for external
|
||||||
|
modules.
|
||||||
|
|
||||||
|
flake.nix:
|
||||||
```nix
|
```nix
|
||||||
with inputs;
|
|
||||||
{
|
{
|
||||||
hmModules = {
|
nixos.hostDefaults.externalModules = [ inputs.agenix.nixosModules.age ];
|
||||||
doom-emacs = doom-emacs.hmModule;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Use:
|
## Home Manager
|
||||||
users/nixos/default.nix:
|
Since there isn't a `hosts` concept for home-manager, externalModules is just a
|
||||||
|
top-level argument in the `home` namespace.
|
||||||
|
|
||||||
|
flake.nix:
|
||||||
```nix
|
```nix
|
||||||
{ hmModules, ... }:
|
|
||||||
{
|
{
|
||||||
home-manager.users.nixos = {
|
home.externalModules = [ doom-emacs = doom-emacs.hmModule ];
|
||||||
imports = [ hmModules.doom-emacs ] ;
|
|
||||||
|
|
||||||
programs.doom-emacs.enable = true;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
[extern]: https://github.com/divnix/devos/tree/core/extern/default.nix
|
> ##### Note:
|
||||||
|
> To avoid declaring "external" modules separately, which is obvious since they come from `inputs`, the optimal solution would be to automatically export modules that were created in
|
||||||
|
> your flake. But this is not possible due to NixOS/nix#4740.
|
||||||
|
|
|
@ -15,6 +15,11 @@ attribute to the name of the file minus the _.nix_ extension. This is for
|
||||||
convenience, since `nixos-rebuild` automatically searches for a configuration
|
convenience, since `nixos-rebuild` automatically searches for a configuration
|
||||||
matching the current systems hostname if one is not specified explicitly.
|
matching the current systems hostname if one is not specified explicitly.
|
||||||
|
|
||||||
|
You can set channels, systems, and add extra modules to each host by editing the
|
||||||
|
`nixos.hosts` argument in flake.nix. This is the perfect place to import
|
||||||
|
host specific modules from external sources, such as the
|
||||||
|
[nixos-hardware][nixos-hardware] repository.
|
||||||
|
|
||||||
It is recommended that the host modules only contain configuration information
|
It is recommended that the host modules only contain configuration information
|
||||||
specific to a particular piece of hardware. Anything reusable across machines
|
specific to a particular piece of hardware. Anything reusable across machines
|
||||||
is best saved for [profile modules](./profiles.md).
|
is best saved for [profile modules](./profiles.md).
|
||||||
|
@ -22,20 +27,29 @@ is best saved for [profile modules](./profiles.md).
|
||||||
This is a good place to import sets of profiles, called [suites](./suites.md),
|
This is a good place to import sets of profiles, called [suites](./suites.md),
|
||||||
that you intend to use on your machine.
|
that you intend to use on your machine.
|
||||||
|
|
||||||
Additionally, this is the perfect place to import anything you might need from
|
|
||||||
the [nixos-hardware][nixos-hardware] repository.
|
|
||||||
|
|
||||||
> ##### _Note:_
|
|
||||||
> Set `nixpkgs.system` to the architecture of this host, default is "x86_64-linux".
|
|
||||||
> Keep in mind that not all packages are available for all architectures.
|
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
|
||||||
|
flake.nix:
|
||||||
|
```nix
|
||||||
|
{
|
||||||
|
nixos.hosts = mkMerge [
|
||||||
|
(devos.lib.importHosts ./hosts)
|
||||||
|
{
|
||||||
|
librem = {
|
||||||
|
channelName = "latest";
|
||||||
|
modules = [ hardware.purism-librem-13v3 ];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
hosts/librem.nix:
|
hosts/librem.nix:
|
||||||
```nix
|
```nix
|
||||||
{ suites, hardware, ... }:
|
{ suites, ... }:
|
||||||
{
|
{
|
||||||
imports = suites.laptop ++ [ hardware.purism-librem-13v3 ];
|
imports = suites.laptop;
|
||||||
|
|
||||||
boot.loader.systemd-boot.enable = true;
|
boot.loader.systemd-boot.enable = true;
|
||||||
boot.loader.efi.canTouchEfiVariables = true;
|
boot.loader.efi.canTouchEfiVariables = true;
|
||||||
|
|
|
@ -1,47 +1,41 @@
|
||||||
# Overrides
|
# Overrides
|
||||||
By default, the NixOS systems are based on unstable. While it is trivial to
|
Each NixOS host follows one channel. But many times it is useful to get packages
|
||||||
change this to a stable release, or any other branch of nixpkgs by
|
or modules from different channels.
|
||||||
changing the flake url, sometimes all we want is a single package from another
|
|
||||||
branch.
|
|
||||||
|
|
||||||
This is what the overrides are for. By default, they are pulled directly from
|
## Packages
|
||||||
nixpkgs/master, but you can change the `override` flake input url to
|
You can make use of `overlays/overrides.nix` to override specific packages in the
|
||||||
nixos-unstable, or even a specific sha revision.
|
default channel to be pulled from other channels. That file is simply an example
|
||||||
|
of how any overlay can get `channels` as their first argument.
|
||||||
|
|
||||||
They are defined in the `extern/overrides.nix` file.
|
You can add overlays to any channel to override packages from other channels.
|
||||||
|
|
||||||
## Example
|
Pulling the manix package from the `latest` channel:
|
||||||
|
|
||||||
### Packages
|
|
||||||
The override packages are defined as a regular overlay with an extra arguement
|
|
||||||
`pkgs`. This refers to the packages built from the `override` flake.
|
|
||||||
|
|
||||||
Pulling the manix package from the override flake:
|
|
||||||
```nix
|
```nix
|
||||||
{
|
channels: final: prev: {
|
||||||
packages = pkgs: final: prev: {
|
__dontExport = true;
|
||||||
inherit (pkgs) manix;
|
inherit (pkgs.latest) manix;
|
||||||
};
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Modules
|
It is recommended to set the `__dontExport` property for override specific
|
||||||
|
overlays. `overlays/overrides.nix` is the best place to consolidate all package
|
||||||
|
overrides and the property is already set for you.
|
||||||
|
|
||||||
You can also pull modules from override. Simply specify their path relative to
|
## Modules
|
||||||
the nixpkgs [modules][nixpkgs-modules] directory. The old version will be added
|
|
||||||
to `disabledModules` and the new version imported into the configuration.
|
|
||||||
|
|
||||||
Pulling the zsh module from the override flake:
|
You can also pull modules from other channels. All modules have access to the
|
||||||
|
`modulesPath` for each channel as `<channelName>ModulesPath`. And you can use
|
||||||
|
`disabledModules` to remove modules from the current channel.
|
||||||
|
|
||||||
|
Pulling the zsh module from the `latest` channel:
|
||||||
```nix
|
```nix
|
||||||
{
|
{ latestModulesPath }: {
|
||||||
modules = [ "programs/zsh/zsh.nix" ];
|
modules = [ "${latestModulesPath}/programs/zsh/zsh.nix" ];
|
||||||
|
disabledModules = [ "programs/zsh/zsh.nix" ];
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
> ##### _Note:_
|
> ##### _Note:_
|
||||||
> Sometimes a modules name will change from one branch to another. This is what
|
> Sometimes a modules name will change from one branch to another.
|
||||||
> the `disabledModules` list is for. If the module name changes, the old
|
|
||||||
> version will not automatically be disabled, so simply put it's old name in
|
|
||||||
> this list to disable it.
|
|
||||||
|
|
||||||
[nixpkgs-modules]: https://github.com/NixOS/nixpkgs/tree/master/nixos/modules
|
[nixpkgs-modules]: https://github.com/NixOS/nixpkgs/tree/master/nixos/modules
|
||||||
|
|
|
@ -6,7 +6,13 @@ profiles. For good examples, check out the suites defined in the community
|
||||||
In the future, we will use suites as a mechanism for deploying various machine
|
In the future, we will use suites as a mechanism for deploying various machine
|
||||||
types which don't depend on hardware, such as vm's and containers.
|
types which don't depend on hardware, such as vm's and containers.
|
||||||
|
|
||||||
They are defined in `profiles/suites.nix`.
|
They are defined with the `suites` argument in either `home` or `nixos` namespace.
|
||||||
|
Suites should be passed as a function that take profiles as an argument.
|
||||||
|
|
||||||
|
The profiles are passed based on the folder names and list passed to the relevant
|
||||||
|
`profiles` argument. In the template's flake.nix `profiles` is set as
|
||||||
|
`[ ./profiles ./users ]` and that corresponds to the `{ profiles, users }` argument
|
||||||
|
pattern.
|
||||||
|
|
||||||
## Definition
|
## Definition
|
||||||
```nix
|
```nix
|
||||||
|
|
|
@ -3,8 +3,7 @@ The lib directory mirrors the upstream concepts of [`nixpkgs:./lib`][nixpkgs-lib
|
||||||
[`nixpkgs:./nixos/lib`][nixpkgs-nixos-lib] and [`nixpkgs:./pkgs/pkgs-lib`][nixpkgs-pkgs-lib],
|
[`nixpkgs:./nixos/lib`][nixpkgs-nixos-lib] and [`nixpkgs:./pkgs/pkgs-lib`][nixpkgs-pkgs-lib],
|
||||||
but also occasionally [`nixpkgs:./pkgs/build-support`][nixpkgs-pkgs-build-support].
|
but also occasionally [`nixpkgs:./pkgs/build-support`][nixpkgs-pkgs-build-support].
|
||||||
|
|
||||||
It comes with functions necesary to declutter `devos` itself, but you are
|
All functions defined in lib can be accessed in modules and packages as `ourlib`.
|
||||||
welcome to extend it to your needs.
|
|
||||||
|
|
||||||
For example:
|
For example:
|
||||||
|
|
||||||
|
|
407
doc/mkFlakeOptions.md
Normal file
407
doc/mkFlakeOptions.md
Normal file
|
@ -0,0 +1,407 @@
|
||||||
|
## channels
|
||||||
|
nixpkgs channels to create
|
||||||
|
|
||||||
|
|
||||||
|
*_Type_*:
|
||||||
|
attribute set of submodules
|
||||||
|
|
||||||
|
|
||||||
|
*_Default_*
|
||||||
|
```
|
||||||
|
{}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## channels.\<name\>.config
|
||||||
|
nixpkgs config for this channel
|
||||||
|
|
||||||
|
|
||||||
|
*_Type_*:
|
||||||
|
attribute set or path convertible to it
|
||||||
|
|
||||||
|
|
||||||
|
*_Default_*
|
||||||
|
```
|
||||||
|
{}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## channels.\<name\>.input
|
||||||
|
nixpkgs flake input to use for this channel
|
||||||
|
|
||||||
|
|
||||||
|
*_Type_*:
|
||||||
|
nix flake
|
||||||
|
|
||||||
|
|
||||||
|
*_Default_*
|
||||||
|
```
|
||||||
|
"inputs.<name>"
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## channels.\<name\>.overlays
|
||||||
|
overlays to apply to this channel
|
||||||
|
these will get exported under the 'overlays' flake output
|
||||||
|
as \<channel\>/\<name\> and any overlay pulled from ${inputs}
|
||||||
|
will be filtered out
|
||||||
|
|
||||||
|
|
||||||
|
*_Type_*:
|
||||||
|
list of valid Nixpkgs overlay or path convertible to its or anything convertible to it
|
||||||
|
|
||||||
|
|
||||||
|
*_Default_*
|
||||||
|
```
|
||||||
|
[]
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## channelsConfig
|
||||||
|
nixpkgs config for all channels
|
||||||
|
|
||||||
|
|
||||||
|
*_Type_*:
|
||||||
|
attribute set or path convertible to it
|
||||||
|
|
||||||
|
|
||||||
|
*_Default_*
|
||||||
|
```
|
||||||
|
{}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## home
|
||||||
|
hosts, modules, suites, and profiles for home-manager
|
||||||
|
|
||||||
|
|
||||||
|
*_Type_*:
|
||||||
|
submodule
|
||||||
|
|
||||||
|
|
||||||
|
*_Default_*
|
||||||
|
```
|
||||||
|
{}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## home.externalModules
|
||||||
|
modules to include that won't be exported
|
||||||
|
meant importing modules from external flakes
|
||||||
|
|
||||||
|
|
||||||
|
*_Type_*:
|
||||||
|
list of valid module or path convertible to its
|
||||||
|
|
||||||
|
|
||||||
|
*_Default_*
|
||||||
|
```
|
||||||
|
[]
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## home.modules
|
||||||
|
modules to include in all hosts and export to homeModules output
|
||||||
|
|
||||||
|
|
||||||
|
*_Type_*:
|
||||||
|
list of path to a modules or anything convertible to it or path convertible to it
|
||||||
|
|
||||||
|
|
||||||
|
*_Default_*
|
||||||
|
```
|
||||||
|
[]
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## home.profiles
|
||||||
|
profile folders that can be collected into suites
|
||||||
|
the name of the argument passed to suites is based
|
||||||
|
on the folder name.
|
||||||
|
[ ./profiles ] => { profiles }:
|
||||||
|
|
||||||
|
|
||||||
|
*_Type_*:
|
||||||
|
list of paths
|
||||||
|
|
||||||
|
|
||||||
|
*_Default_*
|
||||||
|
```
|
||||||
|
[]
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## home.suites
|
||||||
|
Function that takes profiles and returns suites for this config system
|
||||||
|
These can be accessed through the 'suites' special argument.
|
||||||
|
|
||||||
|
|
||||||
|
*_Type_*:
|
||||||
|
function that evaluates to a(n) attrs or path convertible to it
|
||||||
|
|
||||||
|
|
||||||
|
*_Default_*
|
||||||
|
```
|
||||||
|
"<function>"
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## inputs
|
||||||
|
inputs for this flake
|
||||||
|
used to set channel defaults and create registry
|
||||||
|
|
||||||
|
|
||||||
|
*_Type_*:
|
||||||
|
attribute set of nix flakes
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## nixos
|
||||||
|
hosts, modules, suites, and profiles for nixos
|
||||||
|
|
||||||
|
|
||||||
|
*_Type_*:
|
||||||
|
submodule
|
||||||
|
|
||||||
|
|
||||||
|
*_Default_*
|
||||||
|
```
|
||||||
|
{}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## nixos.hostDefaults
|
||||||
|
Defaults for all hosts.
|
||||||
|
the modules passed under hostDefaults will be exported
|
||||||
|
to the 'nixosModules' flake output.
|
||||||
|
They will also be added to all hosts.
|
||||||
|
|
||||||
|
|
||||||
|
*_Type_*:
|
||||||
|
submodule
|
||||||
|
|
||||||
|
|
||||||
|
*_Default_*
|
||||||
|
```
|
||||||
|
{}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## nixos.hostDefaults.channelName
|
||||||
|
Channel this host should follow
|
||||||
|
|
||||||
|
|
||||||
|
*_Type_*:
|
||||||
|
a channel defined in `channels`
|
||||||
|
|
||||||
|
|
||||||
|
*_Default_*
|
||||||
|
```
|
||||||
|
null
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## nixos.hostDefaults.externalModules
|
||||||
|
modules to include that won't be exported
|
||||||
|
meant importing modules from external flakes
|
||||||
|
|
||||||
|
|
||||||
|
*_Type_*:
|
||||||
|
list of valid module or path convertible to its
|
||||||
|
|
||||||
|
|
||||||
|
*_Default_*
|
||||||
|
```
|
||||||
|
[]
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## nixos.hostDefaults.modules
|
||||||
|
modules to include in all hosts and export to nixosModules output
|
||||||
|
|
||||||
|
|
||||||
|
*_Type_*:
|
||||||
|
list of path to a modules or anything convertible to it or path convertible to it
|
||||||
|
|
||||||
|
|
||||||
|
*_Default_*
|
||||||
|
```
|
||||||
|
[]
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## nixos.hostDefaults.system
|
||||||
|
system for this host
|
||||||
|
|
||||||
|
|
||||||
|
*_Type_*:
|
||||||
|
system defined in `supportedSystems`
|
||||||
|
|
||||||
|
|
||||||
|
*_Default_*
|
||||||
|
```
|
||||||
|
null
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## nixos.hosts
|
||||||
|
configurations to include in the nixosConfigurations output
|
||||||
|
|
||||||
|
|
||||||
|
*_Type_*:
|
||||||
|
attribute set of submodules
|
||||||
|
|
||||||
|
|
||||||
|
*_Default_*
|
||||||
|
```
|
||||||
|
{}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## nixos.hosts.\<name\>.channelName
|
||||||
|
Channel this host should follow
|
||||||
|
|
||||||
|
|
||||||
|
*_Type_*:
|
||||||
|
a channel defined in `channels`
|
||||||
|
|
||||||
|
|
||||||
|
*_Default_*
|
||||||
|
```
|
||||||
|
null
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## nixos.hosts.\<name\>.modules
|
||||||
|
modules to include
|
||||||
|
|
||||||
|
|
||||||
|
*_Type_*:
|
||||||
|
list of valid module or path convertible to its or anything convertible to it
|
||||||
|
|
||||||
|
|
||||||
|
*_Default_*
|
||||||
|
```
|
||||||
|
[]
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## nixos.hosts.\<name\>.system
|
||||||
|
system for this host
|
||||||
|
|
||||||
|
|
||||||
|
*_Type_*:
|
||||||
|
system defined in `supportedSystems`
|
||||||
|
|
||||||
|
|
||||||
|
*_Default_*
|
||||||
|
```
|
||||||
|
null
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## nixos.profiles
|
||||||
|
profile folders that can be collected into suites
|
||||||
|
the name of the argument passed to suites is based
|
||||||
|
on the folder name.
|
||||||
|
[ ./profiles ] => { profiles }:
|
||||||
|
|
||||||
|
|
||||||
|
*_Type_*:
|
||||||
|
list of paths
|
||||||
|
|
||||||
|
|
||||||
|
*_Default_*
|
||||||
|
```
|
||||||
|
[]
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## nixos.suites
|
||||||
|
Function that takes profiles and returns suites for this config system
|
||||||
|
These can be accessed through the 'suites' special argument.
|
||||||
|
|
||||||
|
|
||||||
|
*_Type_*:
|
||||||
|
function that evaluates to a(n) attrs or path convertible to it
|
||||||
|
|
||||||
|
|
||||||
|
*_Default_*
|
||||||
|
```
|
||||||
|
"<function>"
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## self
|
||||||
|
The flake to create the devos outputs for
|
||||||
|
|
||||||
|
*_Type_*:
|
||||||
|
nix flake
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## supportedSystems
|
||||||
|
The systems supported by this flake
|
||||||
|
|
||||||
|
|
||||||
|
*_Type_*:
|
||||||
|
list of strings
|
||||||
|
|
||||||
|
|
||||||
|
*_Default_*
|
||||||
|
```
|
||||||
|
["aarch64-linux","i686-linux","x86_64-darwin","x86_64-linux"]
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ we want to keep the process as simple and straightforward as possible.
|
||||||
|
|
||||||
Any _.nix_ files declared in this directory will be assumed to be a valid
|
Any _.nix_ files declared in this directory will be assumed to be a valid
|
||||||
overlay, and will be automatically imported into all [hosts](../concepts/hosts.md), and
|
overlay, and will be automatically imported into all [hosts](../concepts/hosts.md), and
|
||||||
exported via `overlays.<file-basename>` _as well as_
|
exported via `overlays.<channel>/<pkgName>` _as well as_
|
||||||
`packages.<system>.<pkgName>` (for valid systems), so all you have to do is
|
`packages.<system>.<pkgName>` (for valid systems), so all you have to do is
|
||||||
write it.
|
write it.
|
||||||
|
|
||||||
|
|
|
@ -10,10 +10,18 @@ flk up
|
||||||
This will make a new file `hosts/up-$(hostname).nix`, which you can edit to
|
This will make a new file `hosts/up-$(hostname).nix`, which you can edit to
|
||||||
your liking.
|
your liking.
|
||||||
|
|
||||||
|
You must then add a host to `nixos.hosts` in flake.nix:
|
||||||
|
```nix
|
||||||
|
{
|
||||||
|
nixos.hosts = {
|
||||||
|
modules = hosts/NixOS.nix;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
Make sure your `i18n.defaultLocale` and `time.timeZone` are set properly for
|
Make sure your `i18n.defaultLocale` and `time.timeZone` are set properly for
|
||||||
your region. Keep in mind that `networking.hostName` with be automatically
|
your region. Keep in mind that `networking.hostName` will be automatically
|
||||||
set to the filename of your hosts file, so `hosts/my-host.nix` will have the
|
set to the name of your host;
|
||||||
hostname `my-host`.
|
|
||||||
|
|
||||||
Now might be a good time to read the docs on [suites](../concepts/suites.md) and
|
Now might be a good time to read the docs on [suites](../concepts/suites.md) and
|
||||||
[profiles](../concepts/profiles.md) and add or create any that you need.
|
[profiles](../concepts/profiles.md) and add or create any that you need.
|
||||||
|
@ -44,4 +52,3 @@ This calls `nixos-rebuild` with sudo to build and install your configuration.
|
||||||
> simply `sudo nixos-rebuild switch` from anywhere on the system, but it is
|
> simply `sudo nixos-rebuild switch` from anywhere on the system, but it is
|
||||||
> not required.
|
> not required.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ configuration, and, optionally, run them in
|
||||||
|
|
||||||
## Lib Tests
|
## Lib Tests
|
||||||
You can easily write tests for your own library functions in the
|
You can easily write tests for your own library functions in the
|
||||||
___tests/lib.nix___ file and they will be run on every `nix flake check` or
|
lib/___tests/lib.nix___ file and they will be run on every `nix flake check` or
|
||||||
during a CI run.
|
during a CI run.
|
||||||
|
|
||||||
## Unit Tests
|
## Unit Tests
|
||||||
|
|
29
extern/default.nix
vendored
29
extern/default.nix
vendored
|
@ -1,29 +0,0 @@
|
||||||
{ inputs }: with inputs;
|
|
||||||
{
|
|
||||||
modules = [
|
|
||||||
home.nixosModules.home-manager
|
|
||||||
ci-agent.nixosModules.agent-profile
|
|
||||||
];
|
|
||||||
|
|
||||||
overlays = [
|
|
||||||
nur.overlay
|
|
||||||
devshell.overlay
|
|
||||||
(final: prev: {
|
|
||||||
deploy-rs = deploy.packages.${prev.system}.deploy-rs;
|
|
||||||
})
|
|
||||||
pkgs.overlay
|
|
||||||
];
|
|
||||||
|
|
||||||
# passed to all nixos modules
|
|
||||||
specialArgs = {
|
|
||||||
overrideModulesPath = "${override}/nixos/modules";
|
|
||||||
hardware = nixos-hardware.nixosModules;
|
|
||||||
};
|
|
||||||
|
|
||||||
# added to home-manager
|
|
||||||
userModules = [
|
|
||||||
];
|
|
||||||
|
|
||||||
# passed to all home-manager modules
|
|
||||||
userSpecialArgs = { };
|
|
||||||
}
|
|
33
extern/overrides.nix
vendored
33
extern/overrides.nix
vendored
|
@ -1,33 +0,0 @@
|
||||||
# override defaults to nixpkgs/master
|
|
||||||
{
|
|
||||||
# modules to pull from override, stable version is automatically disabled
|
|
||||||
modules = [ ];
|
|
||||||
|
|
||||||
# if a modules name changed in override, add the old name here
|
|
||||||
disabledModules = [ ];
|
|
||||||
|
|
||||||
# packages pulled from override
|
|
||||||
packages = pkgs: final: prev: {
|
|
||||||
inherit (pkgs)
|
|
||||||
cachix
|
|
||||||
dhall
|
|
||||||
discord
|
|
||||||
element-desktop
|
|
||||||
manix
|
|
||||||
nixpkgs-fmt
|
|
||||||
qutebrowser
|
|
||||||
signal-desktop
|
|
||||||
starship;
|
|
||||||
|
|
||||||
haskellPackages = prev.haskellPackages.override {
|
|
||||||
overrides = hfinal: hprev:
|
|
||||||
let version = prev.lib.replaceChars [ "." ] [ "" ] prev.ghc.version;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
# same for haskell packages, matching ghc versions
|
|
||||||
inherit (pkgs.haskell.packages."ghc${version}")
|
|
||||||
haskell-language-server;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
251
flake.lock
251
flake.lock
|
@ -2,9 +2,7 @@
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"ci-agent": {
|
"ci-agent": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-compat": [
|
"flake-compat": "flake-compat",
|
||||||
"flake-compat"
|
|
||||||
],
|
|
||||||
"nix-darwin": [
|
"nix-darwin": [
|
||||||
"darwin"
|
"darwin"
|
||||||
],
|
],
|
||||||
|
@ -12,16 +10,16 @@
|
||||||
"nixos"
|
"nixos"
|
||||||
],
|
],
|
||||||
"nixos-unstable": [
|
"nixos-unstable": [
|
||||||
"override"
|
"latest"
|
||||||
],
|
],
|
||||||
"pre-commit-hooks-nix": "pre-commit-hooks-nix"
|
"pre-commit-hooks-nix": "pre-commit-hooks-nix"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1615131736,
|
"lastModified": 1619088868,
|
||||||
"narHash": "sha256-z4Er9Cj3WpBDO/saLxqb7IypEvVP0/1AnO6rY5NB03Y=",
|
"narHash": "sha256-l9db+HpNIkY41MonGE8z4pbkjBa5BdzJTG5AxV7V7Lw=",
|
||||||
"owner": "hercules-ci",
|
"owner": "hercules-ci",
|
||||||
"repo": "hercules-ci-agent",
|
"repo": "hercules-ci-agent",
|
||||||
"rev": "a1513a51e8efb96e990a562e6e724e17f2789978",
|
"rev": "08f953a263518a3af0ca28cd887020ff3465bdf5",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -33,7 +31,7 @@
|
||||||
"darwin": {
|
"darwin": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
"override"
|
"latest"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
|
@ -52,25 +50,17 @@
|
||||||
},
|
},
|
||||||
"deploy": {
|
"deploy": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-compat": [
|
"flake-compat": "flake-compat_2",
|
||||||
"flake-compat"
|
"naersk": "naersk",
|
||||||
],
|
"nixpkgs": "nixpkgs",
|
||||||
"naersk": [
|
"utils": "utils"
|
||||||
"naersk"
|
|
||||||
],
|
|
||||||
"nixpkgs": [
|
|
||||||
"override"
|
|
||||||
],
|
|
||||||
"utils": [
|
|
||||||
"utils"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1614654775,
|
"lastModified": 1616406726,
|
||||||
"narHash": "sha256-3mLxoxIXSWUuKE8YgIuqM5AZzXFd1aWxkTlplEDeXIA=",
|
"narHash": "sha256-n9zmgxR03QNrvs9/fHewqE0j3SjL7Y+cglBCFu3U3rg=",
|
||||||
"owner": "serokell",
|
"owner": "serokell",
|
||||||
"repo": "deploy-rs",
|
"repo": "deploy-rs",
|
||||||
"rev": "6278b9bef5ad624676a565980417cbbef42d5227",
|
"rev": "9e405fbc5ab5bacbd271fd78c6b6b6877c4d9f8d",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -81,11 +71,11 @@
|
||||||
},
|
},
|
||||||
"devshell": {
|
"devshell": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1613641255,
|
"lastModified": 1618523768,
|
||||||
"narHash": "sha256-iSvjFK4WYAKhuXCCtkY7uy/cFQTzS3D3Ml5WZqjEfL0=",
|
"narHash": "sha256-Gev9da35pHUey3kGz/zrJFc/9ICs++vPCho7qB1mqd8=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "devshell",
|
"repo": "devshell",
|
||||||
"rev": "ff6cffba08600f5b7b43f398fcb58bef023bc4c4",
|
"rev": "709fe4d04a9101c9d224ad83f73416dce71baf21",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -94,20 +84,72 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"flake-compat": {
|
"digga": {
|
||||||
"flake": false,
|
"inputs": {
|
||||||
|
"deploy": "deploy",
|
||||||
|
"devshell": "devshell",
|
||||||
|
"nixlib": "nixlib",
|
||||||
|
"nixpkgs": "nixpkgs_2",
|
||||||
|
"utils": "utils_2"
|
||||||
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1611461076,
|
"lastModified": 1621027569,
|
||||||
"narHash": "sha256-ad++dTtMNeitUIKi1c66aTrVJOSf+mdZTrGrXzjDr6Q=",
|
"narHash": "sha256-ugwMMfZagrWnt6yw+k1YGbydoMQ0OTYJ3WJ1kncsKCg=",
|
||||||
"owner": "BBBSnowball",
|
"owner": "divnix",
|
||||||
"repo": "flake-compat",
|
"repo": "digga",
|
||||||
"rev": "a565cb46bee9fa856a6c15bc9c3bb947fbb784ec",
|
"rev": "c162f5f46206346f431f3905642a8a9f17d42217",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "BBBSnowball",
|
"owner": "divnix",
|
||||||
"ref": "pr-1",
|
"repo": "digga",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"flake-compat": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1606424373,
|
||||||
|
"narHash": "sha256-oq8d4//CJOrVj+EcOaSXvMebvuTkmBJuT5tzlfewUnQ=",
|
||||||
|
"owner": "edolstra",
|
||||||
"repo": "flake-compat",
|
"repo": "flake-compat",
|
||||||
|
"rev": "99f1c2157fba4bfe6211a321fd0ee43199025dbf",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "edolstra",
|
||||||
|
"repo": "flake-compat",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"flake-compat_2": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1606424373,
|
||||||
|
"narHash": "sha256-oq8d4//CJOrVj+EcOaSXvMebvuTkmBJuT5tzlfewUnQ=",
|
||||||
|
"owner": "edolstra",
|
||||||
|
"repo": "flake-compat",
|
||||||
|
"rev": "99f1c2157fba4bfe6211a321fd0ee43199025dbf",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "edolstra",
|
||||||
|
"repo": "flake-compat",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"flake-utils": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1620759905,
|
||||||
|
"narHash": "sha256-WiyWawrgmyN0EdmiHyG2V+fqReiVi8bM9cRdMaKQOFg=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"rev": "b543720b25df6ffdfcf9227afafc5b8c1fabfae8",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -131,10 +173,45 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"latest": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1619400530,
|
||||||
|
"narHash": "sha256-7ZO7B+b9i1wFbHw62EFT+iwuBBpXeA/fcHlR63Z4J0w=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "e8dc8adab655eb27957859c62bef11484b53f639",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"id": "nixpkgs",
|
||||||
|
"type": "indirect"
|
||||||
|
}
|
||||||
|
},
|
||||||
"naersk": {
|
"naersk": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
"override"
|
"latest"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1610392286,
|
||||||
|
"narHash": "sha256-3wFl5y+4YZO4SgRYK8WE7JIS3p0sxbgrGaQ6RMw+d98=",
|
||||||
|
"owner": "nmattia",
|
||||||
|
"repo": "naersk",
|
||||||
|
"rev": "d7bfbad3304fd768c0f93a4c3b50976275e6d4be",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nmattia",
|
||||||
|
"ref": "master",
|
||||||
|
"repo": "naersk",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"naersk_2": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"latest"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
|
@ -151,6 +228,21 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"nixlib": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1620519687,
|
||||||
|
"narHash": "sha256-+6Dd72b2CASuXm2W7KRxZIE7AOy/dj4mU28vaF+zxcs=",
|
||||||
|
"owner": "divnix",
|
||||||
|
"repo": "nixpkgs.lib",
|
||||||
|
"rev": "c7b6169809c5f74dd0c34f3d69e9d12ba4d448de",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "divnix",
|
||||||
|
"repo": "nixpkgs.lib",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"nixos": {
|
"nixos": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1615797423,
|
"lastModified": 1615797423,
|
||||||
|
@ -181,6 +273,37 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1610942247,
|
||||||
|
"narHash": "sha256-PKo1ATAlC6BmfYSRmX0TVmNoFbrec+A5OKcabGEu2yU=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "7d71001b796340b219d1bfa8552c81995017544a",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixpkgs-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs_2": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1620962350,
|
||||||
|
"narHash": "sha256-9ASW4d4/Z8HmRvuJI8rxbEOTbXTBpQ8y+CmFYBwtXzE=",
|
||||||
|
"owner": "nixos",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "5d4a430472cafada97888cc80672fab255231f57",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nixos",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"nur": {
|
"nur": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1615921934,
|
"lastModified": 1615921934,
|
||||||
|
@ -195,20 +318,6 @@
|
||||||
"type": "indirect"
|
"type": "indirect"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"override": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1615926763,
|
|
||||||
"narHash": "sha256-yeq8A3EPNuQVlsxlEQrIRsklfJwJK0Us6jtcG/u8wNs=",
|
|
||||||
"owner": "NixOS",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"rev": "b702a56d417647de4090ac56c0f18bdc7e646610",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"id": "nixpkgs",
|
|
||||||
"type": "indirect"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"pkgs": {
|
"pkgs": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
|
@ -228,11 +337,11 @@
|
||||||
"pre-commit-hooks-nix": {
|
"pre-commit-hooks-nix": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1603721622,
|
"lastModified": 1617783930,
|
||||||
"narHash": "sha256-tUgyf5eYK5+0A/dvLzbbm4W7icxbpORuFMXiFe5yz+I=",
|
"narHash": "sha256-SigoU2LWM1fMggqfM9H8XEIvjOjBVQ/wj/zrn02J28c=",
|
||||||
"owner": "cachix",
|
"owner": "cachix",
|
||||||
"repo": "pre-commit-hooks.nix",
|
"repo": "pre-commit-hooks.nix",
|
||||||
"rev": "efdbd6d28f7f44db3d9f8cf0e0b4cb9db0d259e1",
|
"rev": "2d169bb1b23f3b71a894a66ea81f45c788943248",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -245,26 +354,23 @@
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"ci-agent": "ci-agent",
|
"ci-agent": "ci-agent",
|
||||||
"darwin": "darwin",
|
"darwin": "darwin",
|
||||||
"deploy": "deploy",
|
"digga": "digga",
|
||||||
"devshell": "devshell",
|
|
||||||
"flake-compat": "flake-compat",
|
|
||||||
"home": "home",
|
"home": "home",
|
||||||
"naersk": "naersk",
|
"latest": "latest",
|
||||||
|
"naersk": "naersk_2",
|
||||||
"nixos": "nixos",
|
"nixos": "nixos",
|
||||||
"nixos-hardware": "nixos-hardware",
|
"nixos-hardware": "nixos-hardware",
|
||||||
"nur": "nur",
|
"nur": "nur",
|
||||||
"override": "override",
|
"pkgs": "pkgs"
|
||||||
"pkgs": "pkgs",
|
|
||||||
"utils": "utils"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"utils": {
|
"utils": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1614513358,
|
"lastModified": 1610051610,
|
||||||
"narHash": "sha256-LakhOx3S1dRjnh0b5Dg3mbZyH0ToC9I8Y2wKSkBaTzU=",
|
"narHash": "sha256-U9rPz/usA1/Aohhk7Cmc2gBrEEKRzcW4nwPWMPwja4Y=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "flake-utils",
|
"repo": "flake-utils",
|
||||||
"rev": "5466c5bbece17adaab2d82fae80b46e807611bf3",
|
"rev": "3982c9903e93927c2164caa727cd3f6a0e6d14cc",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -272,6 +378,25 @@
|
||||||
"repo": "flake-utils",
|
"repo": "flake-utils",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"utils_2": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-utils": "flake-utils"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1620801141,
|
||||||
|
"narHash": "sha256-XPJ+/nP/s218E11R+4LJyvkrQXvdT3D6TzNjfWVYZnI=",
|
||||||
|
"owner": "gytis-ivaskevicius",
|
||||||
|
"repo": "flake-utils-plus",
|
||||||
|
"rev": "1a742047f3f7c97b22768ba7738ac5a01052099e",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "gytis-ivaskevicius",
|
||||||
|
"ref": "staging",
|
||||||
|
"repo": "flake-utils-plus",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": "root",
|
"root": "root",
|
||||||
|
|
109
flake.nix
109
flake.nix
|
@ -4,51 +4,94 @@
|
||||||
inputs =
|
inputs =
|
||||||
{
|
{
|
||||||
nixos.url = "nixpkgs/nixos-unstable";
|
nixos.url = "nixpkgs/nixos-unstable";
|
||||||
override.url = "nixpkgs";
|
latest.url = "nixpkgs";
|
||||||
|
digga.url = "github:divnix/digga";
|
||||||
|
|
||||||
ci-agent = {
|
ci-agent = {
|
||||||
url = "github:hercules-ci/hercules-ci-agent";
|
url = "github:hercules-ci/hercules-ci-agent";
|
||||||
inputs = { nix-darwin.follows = "darwin"; flake-compat.follows = "flake-compat"; nixos-20_09.follows = "nixos"; nixos-unstable.follows = "override"; };
|
inputs = { nix-darwin.follows = "darwin"; nixos-20_09.follows = "nixos"; nixos-unstable.follows = "latest"; };
|
||||||
};
|
};
|
||||||
darwin.url = "github:LnL7/nix-darwin";
|
darwin.url = "github:LnL7/nix-darwin";
|
||||||
darwin.inputs.nixpkgs.follows = "override";
|
darwin.inputs.nixpkgs.follows = "latest";
|
||||||
deploy = {
|
|
||||||
url = "github:serokell/deploy-rs";
|
|
||||||
inputs = { flake-compat.follows = "flake-compat"; naersk.follows = "naersk"; nixpkgs.follows = "override"; utils.follows = "utils"; };
|
|
||||||
};
|
|
||||||
devshell.url = "github:numtide/devshell";
|
|
||||||
flake-compat.url = "github:BBBSnowball/flake-compat/pr-1";
|
|
||||||
flake-compat.flake = false;
|
|
||||||
home.url = "github:nix-community/home-manager";
|
home.url = "github:nix-community/home-manager";
|
||||||
home.inputs.nixpkgs.follows = "nixos";
|
home.inputs.nixpkgs.follows = "nixos";
|
||||||
naersk.url = "github:nmattia/naersk";
|
naersk.url = "github:nmattia/naersk";
|
||||||
naersk.inputs.nixpkgs.follows = "override";
|
naersk.inputs.nixpkgs.follows = "latest";
|
||||||
nixos-hardware.url = "github:nixos/nixos-hardware";
|
nixos-hardware.url = "github:nixos/nixos-hardware";
|
||||||
utils.url = "github:numtide/flake-utils";
|
|
||||||
pkgs.url = "path:./pkgs";
|
pkgs.url = "path:./pkgs";
|
||||||
pkgs.inputs.nixpkgs.follows = "nixos";
|
pkgs.inputs.nixpkgs.follows = "nixos";
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = inputs@{ deploy, nixos, nur, self, utils, ... }:
|
outputs = inputs@{ self, pkgs, digga, nixos, ci-agent, home, nixos-hardware, nur, ... }:
|
||||||
let
|
digga.lib.mkFlake {
|
||||||
lib = import ./lib { inherit self nixos utils inputs; };
|
inherit self inputs;
|
||||||
in
|
|
||||||
lib.mkFlake
|
channelsConfig = { allowUnfree = true; };
|
||||||
{
|
|
||||||
inherit self;
|
channels = {
|
||||||
hosts = ./hosts;
|
nixos = {
|
||||||
packages = import ./pkgs;
|
imports = [ (digga.lib.importers.overlays ./overlays) ];
|
||||||
suites = import ./profiles/suites.nix;
|
overlays = [
|
||||||
extern = import ./extern;
|
./pkgs/default.nix
|
||||||
overrides = import ./extern/overrides.nix;
|
pkgs.overlay # for `srcs`
|
||||||
overlays = ./overlays;
|
nur.overlay
|
||||||
profiles = ./profiles;
|
];
|
||||||
userProfiles = ./users/profiles;
|
};
|
||||||
modules = import ./modules/module-list.nix;
|
latest = { };
|
||||||
userModules = import ./users/modules/module-list.nix;
|
};
|
||||||
} // {
|
|
||||||
inherit lib;
|
lib = import ./lib { lib = digga.lib // nixos.lib; };
|
||||||
defaultTemplate = self.templates.flk;
|
|
||||||
|
sharedOverlays = [
|
||||||
|
(final: prev: {
|
||||||
|
lib = prev.lib.extend (lfinal: lprev: {
|
||||||
|
our = self.lib;
|
||||||
|
});
|
||||||
|
})
|
||||||
|
];
|
||||||
|
|
||||||
|
nixos = {
|
||||||
|
hostDefaults = {
|
||||||
|
system = "x86_64-linux";
|
||||||
|
channelName = "nixos";
|
||||||
|
modules = ./modules/module-list.nix;
|
||||||
|
externalModules = [
|
||||||
|
{ _module.args.ourLib = self.lib; }
|
||||||
|
ci-agent.nixosModules.agent-profile
|
||||||
|
home.nixosModules.home-manager
|
||||||
|
./modules/customBuilds.nix
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
imports = [ (digga.lib.importers.hosts ./hosts) ];
|
||||||
|
hosts = {
|
||||||
|
/* set host specific properties here */
|
||||||
|
NixOS = { };
|
||||||
|
};
|
||||||
|
profiles = [ ./profiles ./users ];
|
||||||
|
suites = { profiles, users, ... }: with profiles; {
|
||||||
|
base = [ core users.nixos users.root ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
home = {
|
||||||
|
modules = ./users/modules/module-list.nix;
|
||||||
|
externalModules = [ ];
|
||||||
|
profiles = [ ./users/profiles ];
|
||||||
|
suites = { profiles, ... }: with profiles; {
|
||||||
|
base = [ direnv git ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
homeConfigurations = digga.lib.mkHomeConfigurations self.nixosConfigurations;
|
||||||
|
|
||||||
|
deploy.nodes = digga.lib.mkDeployNodes self.nixosConfigurations { };
|
||||||
|
|
||||||
|
#defaultTemplate = self.templates.flk;
|
||||||
templates.flk.path = ./.;
|
templates.flk.path = ./.;
|
||||||
templates.flk.description = "flk template";
|
templates.flk.description = "flk template";
|
||||||
};
|
|
||||||
|
}
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,45 +0,0 @@
|
||||||
{ lib, ... }:
|
|
||||||
rec {
|
|
||||||
# mapFilterAttrs ::
|
|
||||||
# (name -> value -> bool )
|
|
||||||
# (name -> value -> { name = any; value = any; })
|
|
||||||
# attrs
|
|
||||||
mapFilterAttrs = seive: f: attrs:
|
|
||||||
lib.filterAttrs
|
|
||||||
seive
|
|
||||||
(lib.mapAttrs' f attrs);
|
|
||||||
|
|
||||||
# Generate an attribute set by mapping a function over a list of values.
|
|
||||||
genAttrs' = values: f: lib.listToAttrs (map f values);
|
|
||||||
|
|
||||||
# Convert a list of file paths to attribute set where
|
|
||||||
# the key is the folder or filename stripped of nix
|
|
||||||
# extension and imported content of the file as value.
|
|
||||||
#
|
|
||||||
pathsToImportedAttrs = paths:
|
|
||||||
let
|
|
||||||
paths' = lib.filter
|
|
||||||
(path: lib.hasSuffix ".nix" path
|
|
||||||
|| lib.pathExists "${path}/default.nix")
|
|
||||||
paths;
|
|
||||||
in
|
|
||||||
genAttrs' paths' (path: {
|
|
||||||
name = lib.removeSuffix ".nix"
|
|
||||||
# Safe as long this is just used as a name
|
|
||||||
(builtins.unsafeDiscardStringContext (baseNameOf path));
|
|
||||||
value = import path;
|
|
||||||
});
|
|
||||||
|
|
||||||
concatAttrs = lib.fold (attr: sum: lib.recursiveUpdate sum attr) { };
|
|
||||||
|
|
||||||
# Filter out packages that support given system and follow flake check requirements
|
|
||||||
filterPackages = system: packages:
|
|
||||||
let
|
|
||||||
# Everything that nix flake check requires for the packages output
|
|
||||||
filter = (n: v: with v; let platforms = meta.hydraPlatforms or meta.platforms or [ ]; in
|
|
||||||
lib.isDerivation v && !meta.broken && builtins.elem system platforms);
|
|
||||||
in
|
|
||||||
lib.filterAttrs filter packages;
|
|
||||||
|
|
||||||
safeReadDir = path: lib.optionalAttrs (builtins.pathExists path) (builtins.readDir path);
|
|
||||||
}
|
|
|
@ -1,12 +1,10 @@
|
||||||
let
|
let
|
||||||
inherit (lock.nodes.flake-compat.locked) rev narHash;
|
rev = "e7e5d481a0e15dcd459396e55327749989e04ce0";
|
||||||
|
|
||||||
lock = builtins.fromJSON (builtins.readFile "${../..}/flake.lock");
|
|
||||||
flake = (import
|
flake = (import
|
||||||
(
|
(
|
||||||
fetchTarball {
|
fetchTarball {
|
||||||
url = "https://github.com/edolstra/flake-compat/archive/${rev}.tar.gz";
|
url = "https://github.com/edolstra/flake-compat/archive/${rev}.tar.gz";
|
||||||
sha256 = narHash;
|
sha256 = "0zd3x46fswh5n6faq4x2kkpy6p3c6j593xbdlbsl40ppkclwc80x";
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,28 +1,2 @@
|
||||||
args@{ nixos, self, ... }:
|
{ lib }:
|
||||||
let inherit (nixos) lib; in
|
lib.makeExtensible (self: { })
|
||||||
lib.makeExtensible (final:
|
|
||||||
let callLibs = file: import file
|
|
||||||
({
|
|
||||||
inherit lib;
|
|
||||||
|
|
||||||
dev = final;
|
|
||||||
} // args);
|
|
||||||
in
|
|
||||||
with final;
|
|
||||||
{
|
|
||||||
inherit callLibs;
|
|
||||||
|
|
||||||
attrs = callLibs ./attrs.nix;
|
|
||||||
os = callLibs ./devos;
|
|
||||||
lists = callLibs ./lists.nix;
|
|
||||||
strings = callLibs ./strings.nix;
|
|
||||||
|
|
||||||
mkFlake = callLibs ./mkFlake;
|
|
||||||
|
|
||||||
pkgs-lib = callLibs ./pkgs-lib;
|
|
||||||
|
|
||||||
inherit (attrs) mapFilterAttrs genAttrs' safeReadDir
|
|
||||||
pathsToImportedAttrs concatAttrs filterPackages;
|
|
||||||
inherit (lists) pathsIn;
|
|
||||||
inherit (strings) rgxToString;
|
|
||||||
})
|
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
{ lib, nixos, dev, ... }:
|
|
||||||
{
|
|
||||||
# pkgImport :: Nixpkgs -> Overlays -> System -> Pkgs
|
|
||||||
pkgImport = nixpkgs: overlays: system:
|
|
||||||
import nixpkgs {
|
|
||||||
inherit system overlays;
|
|
||||||
config = { allowUnfree = true; };
|
|
||||||
};
|
|
||||||
|
|
||||||
profileMap = list: map (profile: profile.default) (lib.flatten list);
|
|
||||||
|
|
||||||
mkNodes = dev.callLibs ./mkNodes.nix;
|
|
||||||
|
|
||||||
mkHosts = dev.callLibs ./mkHosts.nix;
|
|
||||||
|
|
||||||
mkSuites = dev.callLibs ./mkSuites.nix;
|
|
||||||
|
|
||||||
mkProfileAttrs = dev.callLibs ./mkProfileAttrs.nix;
|
|
||||||
|
|
||||||
mkPkgs = dev.callLibs ./mkPkgs.nix;
|
|
||||||
|
|
||||||
recImport = dev.callLibs ./recImport.nix;
|
|
||||||
|
|
||||||
devosSystem = dev.callLibs ./devosSystem.nix;
|
|
||||||
|
|
||||||
mkHomeConfigurations = dev.callLibs ./mkHomeConfigurations.nix;
|
|
||||||
|
|
||||||
mkPackages = dev.callLibs ./mkPackages.nix;
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,102 +0,0 @@
|
||||||
{ lib, nixos, self, inputs, ... }:
|
|
||||||
|
|
||||||
{ modules, ... } @ args:
|
|
||||||
lib.nixosSystem (args // {
|
|
||||||
modules =
|
|
||||||
let
|
|
||||||
moduleList = builtins.attrValues modules;
|
|
||||||
modpath = "nixos/modules";
|
|
||||||
|
|
||||||
fullHostConfig = (lib.nixosSystem (args // { modules = moduleList; })).config;
|
|
||||||
|
|
||||||
isoConfig = (lib.nixosSystem
|
|
||||||
(args // {
|
|
||||||
modules = moduleList ++ [
|
|
||||||
|
|
||||||
"${nixos}/${modpath}/installer/cd-dvd/installation-cd-minimal-new-kernel.nix"
|
|
||||||
|
|
||||||
({ config, suites, ... }: {
|
|
||||||
|
|
||||||
# avoid unwanted systemd service startups
|
|
||||||
# all strings in disabledModules get appended to modulesPath
|
|
||||||
# so convert each to list which can be coerced to string
|
|
||||||
disabledModules = map lib.singleton suites.allProfiles;
|
|
||||||
|
|
||||||
nix.registry = lib.mapAttrs (n: v: { flake = v; }) inputs;
|
|
||||||
|
|
||||||
isoImage.isoBaseName = "nixos-" + config.networking.hostName;
|
|
||||||
isoImage.contents = [{
|
|
||||||
source = self;
|
|
||||||
target = "/devos/";
|
|
||||||
}];
|
|
||||||
isoImage.storeContents = [
|
|
||||||
self.devShell.${config.nixpkgs.system}
|
|
||||||
# include also closures that are "switched off" by the
|
|
||||||
# above profile filter on the local config attribute
|
|
||||||
fullHostConfig.system.build.toplevel
|
|
||||||
];
|
|
||||||
# still pull in tools of deactivated profiles
|
|
||||||
environment.systemPackages = fullHostConfig.environment.systemPackages;
|
|
||||||
|
|
||||||
# confilcts with networking.wireless which might be slightly
|
|
||||||
# more useful on a stick
|
|
||||||
networking.networkmanager.enable = lib.mkForce false;
|
|
||||||
# confilcts with networking.wireless
|
|
||||||
networking.wireless.iwd.enable = lib.mkForce false;
|
|
||||||
|
|
||||||
# Set up a link-local boostrap network
|
|
||||||
# See also: https://github.com/NixOS/nixpkgs/issues/75515#issuecomment-571661659
|
|
||||||
networking.usePredictableInterfaceNames = lib.mkForce true; # so prefix matching works
|
|
||||||
networking.useNetworkd = lib.mkForce true;
|
|
||||||
networking.useDHCP = lib.mkForce false;
|
|
||||||
networking.dhcpcd.enable = lib.mkForce false;
|
|
||||||
systemd.network = {
|
|
||||||
# https://www.freedesktop.org/software/systemd/man/systemd.network.html
|
|
||||||
networks."boostrap-link-local" = {
|
|
||||||
matchConfig = {
|
|
||||||
Name = "en* wl* ww*";
|
|
||||||
};
|
|
||||||
networkConfig = {
|
|
||||||
Description = "Link-local host bootstrap network";
|
|
||||||
MulticastDNS = true;
|
|
||||||
LinkLocalAddressing = "ipv6";
|
|
||||||
DHCP = "yes";
|
|
||||||
};
|
|
||||||
address = [
|
|
||||||
# fall back well-known link-local for situations where MulticastDNS is not available
|
|
||||||
"fe80::47" # 47: n=14 i=9 x=24; n+i+x
|
|
||||||
];
|
|
||||||
extraConfig = ''
|
|
||||||
# Unique, yet stable. Based off the MAC address.
|
|
||||||
IPv6LinkLocalAddressGenerationMode = "eui64"
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
|
||||||
})
|
|
||||||
];
|
|
||||||
})).config;
|
|
||||||
hmConfig = (lib.nixosSystem
|
|
||||||
(args // {
|
|
||||||
modules = moduleList ++ [
|
|
||||||
({ config, ... }: {
|
|
||||||
home-manager.useUserPackages = lib.mkForce false;
|
|
||||||
home-manager.sharedModules = [
|
|
||||||
{
|
|
||||||
home.sessionVariables = {
|
|
||||||
inherit (config.environment.sessionVariables) NIX_PATH;
|
|
||||||
};
|
|
||||||
xdg.configFile."nix/registry.json".text =
|
|
||||||
config.environment.etc."nix/registry.json".text;
|
|
||||||
}
|
|
||||||
];
|
|
||||||
})
|
|
||||||
];
|
|
||||||
})).config;
|
|
||||||
in
|
|
||||||
moduleList ++ [{
|
|
||||||
system.build = {
|
|
||||||
iso = isoConfig.system.build.isoImage;
|
|
||||||
homes = hmConfig.home-manager.users;
|
|
||||||
};
|
|
||||||
}];
|
|
||||||
})
|
|
|
@ -1,12 +0,0 @@
|
||||||
{ lib, self, ... }:
|
|
||||||
|
|
||||||
with lib;
|
|
||||||
let
|
|
||||||
mkHomes = host: config:
|
|
||||||
mapAttrs' (user: v: nameValuePair "${user}@${host}" v.home)
|
|
||||||
config.config.system.build.homes;
|
|
||||||
|
|
||||||
hmConfigs = mapAttrs mkHomes self.nixosConfigurations;
|
|
||||||
|
|
||||||
in
|
|
||||||
foldl recursiveUpdate { } (attrValues hmConfigs)
|
|
|
@ -1,109 +0,0 @@
|
||||||
{ lib, dev, nixos, inputs, self, ... }:
|
|
||||||
|
|
||||||
{ dir, extern, suites, overrides, multiPkgs, ... }:
|
|
||||||
let
|
|
||||||
defaultSystem = "x86_64-linux";
|
|
||||||
|
|
||||||
experimentalFeatures = [
|
|
||||||
"flakes"
|
|
||||||
"nix-command"
|
|
||||||
"ca-references"
|
|
||||||
"ca-derivations"
|
|
||||||
];
|
|
||||||
|
|
||||||
modules = {
|
|
||||||
modOverrides = { config, overrideModulesPath, ... }:
|
|
||||||
let
|
|
||||||
inherit (overrides) modules disabledModules;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
disabledModules = modules ++ disabledModules;
|
|
||||||
imports = map
|
|
||||||
(path: "${overrideModulesPath}/${path}")
|
|
||||||
modules;
|
|
||||||
};
|
|
||||||
|
|
||||||
global = { config, pkgs, ... }: {
|
|
||||||
home-manager = {
|
|
||||||
useGlobalPkgs = true;
|
|
||||||
useUserPackages = true;
|
|
||||||
|
|
||||||
extraSpecialArgs = extern.userSpecialArgs // { suites = suites.user; };
|
|
||||||
sharedModules = extern.userModules ++ (builtins.attrValues self.homeModules);
|
|
||||||
};
|
|
||||||
users.mutableUsers = lib.mkDefault false;
|
|
||||||
|
|
||||||
hardware.enableRedistributableFirmware = lib.mkDefault true;
|
|
||||||
|
|
||||||
nix.nixPath = [
|
|
||||||
"nixpkgs=${nixos}"
|
|
||||||
"nixos-config=${self}/lib/compat/nixos"
|
|
||||||
"home-manager=${inputs.home}"
|
|
||||||
];
|
|
||||||
|
|
||||||
nixpkgs.pkgs = lib.mkDefault multiPkgs.${config.nixpkgs.system};
|
|
||||||
|
|
||||||
nix.registry = {
|
|
||||||
devos.flake = self;
|
|
||||||
nixos.flake = nixos;
|
|
||||||
override.flake = inputs.override;
|
|
||||||
};
|
|
||||||
|
|
||||||
nix.package = pkgs.nixFlakes;
|
|
||||||
|
|
||||||
nix.extraOptions = ''
|
|
||||||
experimental-features = ${lib.concatStringsSep " "
|
|
||||||
experimentalFeatures
|
|
||||||
}
|
|
||||||
'';
|
|
||||||
|
|
||||||
system.configurationRevision = lib.mkIf (self ? rev) self.rev;
|
|
||||||
};
|
|
||||||
|
|
||||||
# Everything in `./modules/list.nix`.
|
|
||||||
flakeModules = { imports = builtins.attrValues self.nixosModules ++ extern.modules; };
|
|
||||||
|
|
||||||
cachix = let rootCachix = ../../cachix.nix; in
|
|
||||||
if builtins.pathExists rootCachix
|
|
||||||
then rootCachix
|
|
||||||
else { }
|
|
||||||
;
|
|
||||||
};
|
|
||||||
|
|
||||||
specialArgs = extern.specialArgs // { suites = suites.system; };
|
|
||||||
|
|
||||||
mkHostConfig = hostName:
|
|
||||||
let
|
|
||||||
local = {
|
|
||||||
require = [
|
|
||||||
"${dir}/${hostName}.nix"
|
|
||||||
];
|
|
||||||
|
|
||||||
networking = { inherit hostName; };
|
|
||||||
|
|
||||||
_module.args = {
|
|
||||||
inherit self;
|
|
||||||
hosts = builtins.mapAttrs (_: host: host.config)
|
|
||||||
(removeAttrs hosts [ hostName ]);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
lib = {
|
|
||||||
lib = { inherit specialArgs; };
|
|
||||||
lib.testModule = {
|
|
||||||
imports = [ local ] ++ builtins.attrValues modules;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
in
|
|
||||||
dev.os.devosSystem {
|
|
||||||
inherit specialArgs;
|
|
||||||
system = defaultSystem;
|
|
||||||
modules = modules // { inherit local lib; };
|
|
||||||
};
|
|
||||||
|
|
||||||
hosts = dev.os.recImport
|
|
||||||
{
|
|
||||||
inherit dir;
|
|
||||||
_import = mkHostConfig;
|
|
||||||
};
|
|
||||||
in
|
|
||||||
hosts
|
|
|
@ -1,16 +0,0 @@
|
||||||
{ lib, ... }:
|
|
||||||
|
|
||||||
/**
|
|
||||||
Synopsis: mkNodes _nixosConfigurations_
|
|
||||||
|
|
||||||
Generate the `nodes` attribute expected by deploy-rs
|
|
||||||
where _nixosConfigurations_ are `nodes`.
|
|
||||||
**/
|
|
||||||
deploy: lib.mapAttrs (_: config: {
|
|
||||||
hostname = config.config.networking.hostName;
|
|
||||||
|
|
||||||
profiles.system = {
|
|
||||||
user = "root";
|
|
||||||
path = deploy.lib.x86_64-linux.activate.nixos config;
|
|
||||||
};
|
|
||||||
})
|
|
|
@ -1,18 +0,0 @@
|
||||||
{ lib, dev, self, ... }:
|
|
||||||
|
|
||||||
{ pkgs }:
|
|
||||||
let
|
|
||||||
inherit (self) overlay overlays;
|
|
||||||
packagesNames = lib.attrNames (overlay null null)
|
|
||||||
++ lib.attrNames (dev.concatAttrs
|
|
||||||
(lib.attrValues
|
|
||||||
(lib.mapAttrs (_: v: v null null) overlays)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
in
|
|
||||||
lib.fold
|
|
||||||
(key: sum: lib.recursiveUpdate sum {
|
|
||||||
${key} = pkgs.${key};
|
|
||||||
})
|
|
||||||
{ }
|
|
||||||
packagesNames
|
|
|
@ -1,27 +0,0 @@
|
||||||
{ lib, dev, nixos, self, inputs, ... }:
|
|
||||||
|
|
||||||
{ extern, overrides }:
|
|
||||||
(inputs.utils.lib.eachDefaultSystem
|
|
||||||
(system:
|
|
||||||
let
|
|
||||||
overridePkgs = dev.os.pkgImport inputs.override [ ] system;
|
|
||||||
overridesOverlay = overrides.packages;
|
|
||||||
|
|
||||||
overlays = [
|
|
||||||
(final: prev: {
|
|
||||||
lib = prev.lib.extend (lfinal: lprev: {
|
|
||||||
inherit dev;
|
|
||||||
inherit (lib) nixosSystem;
|
|
||||||
|
|
||||||
utils = inputs.utils.lib;
|
|
||||||
});
|
|
||||||
})
|
|
||||||
(overridesOverlay overridePkgs)
|
|
||||||
self.overlay
|
|
||||||
]
|
|
||||||
++ extern.overlays
|
|
||||||
++ (lib.attrValues self.overlays);
|
|
||||||
in
|
|
||||||
{ pkgs = dev.os.pkgImport nixos overlays system; }
|
|
||||||
)
|
|
||||||
).pkgs
|
|
|
@ -1,35 +0,0 @@
|
||||||
{ lib, dev, ... }:
|
|
||||||
|
|
||||||
let mkProfileAttrs =
|
|
||||||
/**
|
|
||||||
Synopsis: mkProfileAttrs _path_
|
|
||||||
|
|
||||||
Recursively collect the subdirs of _path_ containing a default.nix into attrs.
|
|
||||||
This sets a contract, eliminating ambiguity for _default.nix_ living under the
|
|
||||||
profile directory.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
let profiles = mkProfileAttrs ./profiles; in
|
|
||||||
assert profiles ? core.default; 0
|
|
||||||
**/
|
|
||||||
dir:
|
|
||||||
let
|
|
||||||
imports =
|
|
||||||
let
|
|
||||||
files = dev.safeReadDir dir;
|
|
||||||
|
|
||||||
p = n: v:
|
|
||||||
v == "directory"
|
|
||||||
&& n != "profiles";
|
|
||||||
in
|
|
||||||
lib.filterAttrs p files;
|
|
||||||
|
|
||||||
f = n: _:
|
|
||||||
lib.optionalAttrs
|
|
||||||
(lib.pathExists "${dir}/${n}/default.nix")
|
|
||||||
{ default = "${dir}/${n}"; }
|
|
||||||
// mkProfileAttrs "${dir}/${n}";
|
|
||||||
in
|
|
||||||
lib.mapAttrs f imports;
|
|
||||||
in mkProfileAttrs
|
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
{ lib, dev, ... }:
|
|
||||||
|
|
||||||
{ users, profiles, userProfiles, suites } @ args:
|
|
||||||
let
|
|
||||||
inherit (dev) os;
|
|
||||||
|
|
||||||
definedSuites = suites {
|
|
||||||
inherit (args) users profiles userProfiles;
|
|
||||||
};
|
|
||||||
|
|
||||||
allProfiles =
|
|
||||||
let defaults = lib.collect (x: x ? default) profiles;
|
|
||||||
in map (x: x.default) defaults;
|
|
||||||
|
|
||||||
allUsers =
|
|
||||||
let defaults = lib.collect (x: x ? default) users;
|
|
||||||
in map (x: x.default) defaults;
|
|
||||||
|
|
||||||
createSuites = _: suites: lib.mapAttrs (_: v: os.profileMap v) suites // {
|
|
||||||
inherit allProfiles allUsers;
|
|
||||||
};
|
|
||||||
|
|
||||||
in
|
|
||||||
lib.mapAttrs createSuites definedSuites
|
|
|
@ -1,12 +0,0 @@
|
||||||
{ lib, dev, ... }:
|
|
||||||
|
|
||||||
{ dir, _import ? base: import "${dir}/${base}.nix" }:
|
|
||||||
dev.mapFilterAttrs
|
|
||||||
(_: v: v != null)
|
|
||||||
(n: v:
|
|
||||||
if n != "default.nix" && lib.hasSuffix ".nix" n && v == "regular"
|
|
||||||
then
|
|
||||||
let name = lib.removeSuffix ".nix" n; in lib.nameValuePair (name) (_import name)
|
|
||||||
else
|
|
||||||
lib.nameValuePair ("") (null))
|
|
||||||
(dev.safeReadDir dir)
|
|
|
@ -1,8 +0,0 @@
|
||||||
{ lib, dev, ... }:
|
|
||||||
{
|
|
||||||
pathsIn = dir:
|
|
||||||
let
|
|
||||||
fullPath = name: "${toString dir}/${name}";
|
|
||||||
in
|
|
||||||
map fullPath (lib.attrNames (dev.safeReadDir dir));
|
|
||||||
}
|
|
|
@ -1,55 +0,0 @@
|
||||||
{ dev, nixos, inputs, ... }:
|
|
||||||
let
|
|
||||||
inherit (dev) os;
|
|
||||||
inherit (inputs) utils deploy;
|
|
||||||
evalFlakeArgs = dev.callLibs ./evalArgs.nix;
|
|
||||||
in
|
|
||||||
|
|
||||||
{ self, ... } @ args:
|
|
||||||
let
|
|
||||||
|
|
||||||
cfg = (evalFlakeArgs { inherit args; }).config;
|
|
||||||
|
|
||||||
multiPkgs = os.mkPkgs { inherit (cfg) extern overrides; };
|
|
||||||
|
|
||||||
outputs = {
|
|
||||||
nixosConfigurations = os.mkHosts {
|
|
||||||
inherit self multiPkgs;
|
|
||||||
inherit (cfg) extern suites overrides;
|
|
||||||
dir = cfg.hosts;
|
|
||||||
};
|
|
||||||
|
|
||||||
homeConfigurations = os.mkHomeConfigurations;
|
|
||||||
|
|
||||||
nixosModules = cfg.modules;
|
|
||||||
|
|
||||||
homeModules = cfg.userModules;
|
|
||||||
|
|
||||||
overlay = cfg.packages;
|
|
||||||
inherit (cfg) overlays;
|
|
||||||
|
|
||||||
deploy.nodes = os.mkNodes deploy self.nixosConfigurations;
|
|
||||||
};
|
|
||||||
|
|
||||||
systemOutputs = utils.lib.eachDefaultSystem (system:
|
|
||||||
let
|
|
||||||
pkgs = multiPkgs.${system};
|
|
||||||
pkgs-lib = dev.pkgs-lib.${system};
|
|
||||||
# all packages that are defined in ./pkgs
|
|
||||||
legacyPackages = os.mkPackages { inherit pkgs; };
|
|
||||||
in
|
|
||||||
{
|
|
||||||
checks = pkgs-lib.tests.mkChecks {
|
|
||||||
inherit (self.deploy) nodes;
|
|
||||||
hosts = self.nixosConfigurations;
|
|
||||||
homes = self.homeConfigurations;
|
|
||||||
};
|
|
||||||
|
|
||||||
inherit legacyPackages;
|
|
||||||
packages = dev.filterPackages system legacyPackages;
|
|
||||||
|
|
||||||
devShell = pkgs-lib.shell;
|
|
||||||
});
|
|
||||||
in
|
|
||||||
outputs // systemOutputs
|
|
||||||
|
|
|
@ -1,154 +0,0 @@
|
||||||
{ self, dev, nixos, inputs, ... }:
|
|
||||||
|
|
||||||
{ args }:
|
|
||||||
let
|
|
||||||
argOpts = with nixos.lib; { config, options, ... }:
|
|
||||||
let
|
|
||||||
inherit (dev) os;
|
|
||||||
|
|
||||||
inherit (config) self;
|
|
||||||
|
|
||||||
inputAttrs = with types; functionTo attrs;
|
|
||||||
moduleType = with types; anything // {
|
|
||||||
inherit (submodule { }) check;
|
|
||||||
description = "valid module";
|
|
||||||
};
|
|
||||||
in
|
|
||||||
{
|
|
||||||
options = with types; {
|
|
||||||
self = mkOption {
|
|
||||||
type = addCheck attrs nixos.lib.isStorePath;
|
|
||||||
description = "The flake to create the devos outputs for";
|
|
||||||
};
|
|
||||||
hosts = mkOption {
|
|
||||||
type = path;
|
|
||||||
default = "${self}/hosts";
|
|
||||||
defaultText = "\${self}/hosts";
|
|
||||||
apply = toString;
|
|
||||||
description = ''
|
|
||||||
Path to directory containing host configurations that will be exported
|
|
||||||
to the 'nixosConfigurations' output.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
packages = mkOption {
|
|
||||||
# functionTo changes arg names which breaks flake check
|
|
||||||
type = types.anything // {
|
|
||||||
check = builtins.isFunction;
|
|
||||||
description = "Nixpkgs overlay";
|
|
||||||
};
|
|
||||||
default = (final: prev: { });
|
|
||||||
defaultText = "(final: prev: {})";
|
|
||||||
description = ''
|
|
||||||
Overlay for custom packages that will be included in treewide 'pkgs'.
|
|
||||||
This should follow the standard nixpkgs overlay format - two argument function
|
|
||||||
that returns an attrset.
|
|
||||||
These packages will be exported to the 'packages' and 'legacyPackages' outputs.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
modules = mkOption {
|
|
||||||
type = listOf moduleType;
|
|
||||||
default = [ ];
|
|
||||||
apply = dev.pathsToImportedAttrs;
|
|
||||||
description = ''
|
|
||||||
list of modules to include in confgurations and export in 'nixosModules' output
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
userModules = mkOption {
|
|
||||||
type = listOf moduleType;
|
|
||||||
default = [ ];
|
|
||||||
apply = dev.pathsToImportedAttrs;
|
|
||||||
description = ''
|
|
||||||
list of modules to include in home-manager configurations and export in
|
|
||||||
'homeModules' output
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
profiles = mkOption {
|
|
||||||
type = path;
|
|
||||||
default = "${self}/profiles";
|
|
||||||
defaultText = "\${self}/profiles";
|
|
||||||
apply = x: os.mkProfileAttrs (toString x);
|
|
||||||
description = "path to profiles folder that can be collected into suites";
|
|
||||||
};
|
|
||||||
userProfiles = mkOption {
|
|
||||||
type = path;
|
|
||||||
default = "${self}/users/profiles";
|
|
||||||
defaultText = "\${self}/users/profiles";
|
|
||||||
apply = x: os.mkProfileAttrs (toString x);
|
|
||||||
description = "path to user profiles folder that can be collected into userSuites";
|
|
||||||
};
|
|
||||||
suites =
|
|
||||||
let
|
|
||||||
defaults = { user = { }; system = { }; };
|
|
||||||
in
|
|
||||||
mkOption {
|
|
||||||
type = inputAttrs;
|
|
||||||
default = { ... }: defaults;
|
|
||||||
defaultText = "{ user = {}; system = {}; }";
|
|
||||||
apply = suites: defaults // os.mkSuites {
|
|
||||||
inherit suites;
|
|
||||||
inherit (config) profiles users userProfiles;
|
|
||||||
};
|
|
||||||
description = ''
|
|
||||||
Function with inputs 'users' and 'profiles' that returns attribute set
|
|
||||||
with user and system suites. The former for Home Manager and the latter
|
|
||||||
for nixos configurations.
|
|
||||||
These can be accessed through the 'suites' specialArg in each config system.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
users = mkOption {
|
|
||||||
type = path;
|
|
||||||
default = "${self}/users";
|
|
||||||
defaultText = "\${self}/users";
|
|
||||||
apply = x: os.mkProfileAttrs (toString x);
|
|
||||||
description = ''
|
|
||||||
path to folder containing profiles that define system users
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
extern =
|
|
||||||
let
|
|
||||||
defaults = {
|
|
||||||
modules = [ ];
|
|
||||||
overlays = [ ];
|
|
||||||
specialArgs = { };
|
|
||||||
userModules = [ ];
|
|
||||||
userSpecialArgs = { };
|
|
||||||
};
|
|
||||||
in
|
|
||||||
mkOption {
|
|
||||||
type = inputAttrs;
|
|
||||||
default = { ... }: defaults;
|
|
||||||
defaultText = ''
|
|
||||||
{ modules = []; overlays = []; specialArgs = []; userModules = []; userSpecialArgs = []; }
|
|
||||||
'';
|
|
||||||
# So unneeded extern attributes can safely be deleted
|
|
||||||
apply = x: defaults // (x { inputs = inputs // self.inputs; });
|
|
||||||
description = ''
|
|
||||||
Function with argument 'inputs' that contains all devos and ''${self}'s inputs.
|
|
||||||
The function should return an attribute set with modules, overlays, and
|
|
||||||
specialArgs to be included across nixos and home manager configurations.
|
|
||||||
Only attributes that are used should be returned.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
overlays = mkOption {
|
|
||||||
type = path;
|
|
||||||
default = "${self}/overlays";
|
|
||||||
defaultText = "\${self}/overlays";
|
|
||||||
apply = x: dev.pathsToImportedAttrs (dev.pathsIn (toString x));
|
|
||||||
description = ''
|
|
||||||
path to folder containing overlays which will be applied to pkgs and exported in
|
|
||||||
the 'overlays' output
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
overrides = mkOption rec {
|
|
||||||
type = attrs;
|
|
||||||
default = { modules = [ ]; disabledModules = [ ]; packages = _: _: _: { }; };
|
|
||||||
defaultText = "{ modules = []; disabledModules = []; packages = {}; }";
|
|
||||||
apply = x: default // x;
|
|
||||||
description = "attrset of packages and modules that will be pulled from nixpkgs master";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
in
|
|
||||||
nixos.lib.evalModules {
|
|
||||||
modules = [ argOpts args ];
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
args@{ lib, dev, utils, nixos, ... }:
|
|
||||||
lib.genAttrs utils.lib.defaultSystems (system:
|
|
||||||
lib.makeExtensible (final:
|
|
||||||
let
|
|
||||||
pkgs = import nixos { inherit system; };
|
|
||||||
callLibs = file: import file
|
|
||||||
(args // {
|
|
||||||
inherit pkgs system;
|
|
||||||
pkgs-lib = final;
|
|
||||||
});
|
|
||||||
in
|
|
||||||
with final;
|
|
||||||
{
|
|
||||||
inherit callLibs;
|
|
||||||
|
|
||||||
tests = callLibs ./tests;
|
|
||||||
shell = callLibs ./shell;
|
|
||||||
}
|
|
||||||
)
|
|
||||||
)
|
|
|
@ -1,49 +0,0 @@
|
||||||
{ lib, dev, inputs, system, nixos, ... }:
|
|
||||||
let
|
|
||||||
overlays = [
|
|
||||||
inputs.devshell.overlay
|
|
||||||
(final: prev: {
|
|
||||||
deploy-rs =
|
|
||||||
inputs.deploy.packages.${prev.system}.deploy-rs;
|
|
||||||
})
|
|
||||||
];
|
|
||||||
|
|
||||||
pkgs = dev.os.pkgImport nixos overlays system;
|
|
||||||
|
|
||||||
flk = pkgs.callPackage ./flk.nix { };
|
|
||||||
|
|
||||||
installPkgs = (lib.nixosSystem {
|
|
||||||
inherit system;
|
|
||||||
modules = [ ];
|
|
||||||
}).config.system.build;
|
|
||||||
in
|
|
||||||
pkgs.devshell.mkShell {
|
|
||||||
imports = [ (pkgs.devshell.importTOML ./devshell.toml) ];
|
|
||||||
|
|
||||||
packages = with installPkgs; [
|
|
||||||
nixos-install
|
|
||||||
nixos-generate-config
|
|
||||||
nixos-enter
|
|
||||||
];
|
|
||||||
|
|
||||||
git.hooks = {
|
|
||||||
pre-commit.text = lib.fileContents ./pre-commit.sh;
|
|
||||||
};
|
|
||||||
|
|
||||||
commands = with pkgs; [
|
|
||||||
{ package = flk; }
|
|
||||||
{
|
|
||||||
name = "nix";
|
|
||||||
help = pkgs.nixFlakes.meta.description;
|
|
||||||
command = ''
|
|
||||||
${pkgs.nixFlakes}/bin/nix --experimental-features "nix-command flakes ca-references" "${"\${@}"}"
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
]
|
|
||||||
++ lib.optional (system != "i686-linux") { package = cachix; }
|
|
||||||
++ lib.optional (system == "x86_64-linux") {
|
|
||||||
name = "deploy";
|
|
||||||
package = deploy-rs;
|
|
||||||
help = "A simple multi-profile Nix-flake deploy tool.";
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -1,29 +0,0 @@
|
||||||
imports = [ "git.hooks" ]
|
|
||||||
|
|
||||||
[devshell]
|
|
||||||
packages = [
|
|
||||||
"git-crypt"
|
|
||||||
]
|
|
||||||
|
|
||||||
[[commands]]
|
|
||||||
package = "git"
|
|
||||||
category = "vcs"
|
|
||||||
|
|
||||||
[[commands]]
|
|
||||||
package = "nixpkgs-fmt"
|
|
||||||
category = "linters"
|
|
||||||
|
|
||||||
[[commands]]
|
|
||||||
package = "editorconfig-checker"
|
|
||||||
category = "linters"
|
|
||||||
|
|
||||||
[[commands]]
|
|
||||||
package = "python3Packages.grip"
|
|
||||||
category = "documentation"
|
|
||||||
|
|
||||||
[[commands]]
|
|
||||||
package = "mdbook"
|
|
||||||
category = "documentation"
|
|
||||||
|
|
||||||
[git.hooks]
|
|
||||||
enable = true
|
|
|
@ -1,23 +0,0 @@
|
||||||
{ stdenv }:
|
|
||||||
let
|
|
||||||
name = "flk";
|
|
||||||
in
|
|
||||||
stdenv.mkDerivation {
|
|
||||||
inherit name;
|
|
||||||
|
|
||||||
src = ./flk.sh;
|
|
||||||
|
|
||||||
dontUnpack = true;
|
|
||||||
dontBuild = true;
|
|
||||||
|
|
||||||
installPhase = ''
|
|
||||||
mkdir -p $out/bin
|
|
||||||
install $src $out/bin/${name}
|
|
||||||
'';
|
|
||||||
|
|
||||||
checkPhase = ''
|
|
||||||
${stdenv.shell} -n -O extglob $out/bin/${name}
|
|
||||||
'';
|
|
||||||
|
|
||||||
meta.description = "Build, deploy, and install NixOS";
|
|
||||||
}
|
|
|
@ -1,98 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
[[ -d "$DEVSHELL_ROOT" ]] ||
|
|
||||||
{
|
|
||||||
echo "This script must be run from devos's devshell" >&2
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
shopt -s extglob
|
|
||||||
|
|
||||||
HOSTNAME="$(hostname)"
|
|
||||||
|
|
||||||
usage () {
|
|
||||||
printf "%b\n" \
|
|
||||||
"\e[4mUsage\e[0m: $(basename $0) COMMAND [ARGS]\n" \
|
|
||||||
"\e[4mCommands\e[0m:"
|
|
||||||
|
|
||||||
printf " %-30s %s\n\n" \
|
|
||||||
"up" "Generate $DEVSHELL_ROOT/hosts/up-$HOSTNAME.nix" \
|
|
||||||
"update [INPUT]" "Update and commit the lock file, or specific input" \
|
|
||||||
"get (core|community) [DEST]" "Copy the desired template to DEST" \
|
|
||||||
"iso HOST" "Generate an ISO image of HOST" \
|
|
||||||
"install HOST [ARGS]" "Shortcut for nixos-install" \
|
|
||||||
"home HOST USER [switch]" "Home-manager config of USER from HOST" \
|
|
||||||
"HOST (switch|boot|test)" "Shortcut for nixos-rebuild"
|
|
||||||
}
|
|
||||||
|
|
||||||
case "$1" in
|
|
||||||
""|"-h"|"help"|*(-)"help")
|
|
||||||
usage
|
|
||||||
;;
|
|
||||||
|
|
||||||
"up")
|
|
||||||
mkdir -p "$DEVSHELL_ROOT/up"
|
|
||||||
|
|
||||||
nixos-generate-config --dir "$DEVSHELL_ROOT/up/$HOSTNAME"
|
|
||||||
|
|
||||||
printf "%s\n" \
|
|
||||||
"{ suites, ... }:" \
|
|
||||||
"{" \
|
|
||||||
" imports = [" \
|
|
||||||
" ../up/$HOSTNAME/configuration.nix" \
|
|
||||||
" ] ++ suites.core;" \
|
|
||||||
"}" > "$DEVSHELL_ROOT/hosts/up-$HOSTNAME.nix"
|
|
||||||
|
|
||||||
git add -f \
|
|
||||||
"$DEVSHELL_ROOT/up/$HOSTNAME" \
|
|
||||||
"$DEVSHELL_ROOT/hosts/up-$HOSTNAME.nix"
|
|
||||||
;;
|
|
||||||
|
|
||||||
"update")
|
|
||||||
if [[ -n "$2" ]]; then
|
|
||||||
if [[ -n "$3" ]]; then
|
|
||||||
(cd $2; nix flake list-inputs --update-input "$3")
|
|
||||||
else
|
|
||||||
(cd $2; nix flake update)
|
|
||||||
fi
|
|
||||||
nix flake list-inputs --update-input "$2" "$DEVSHELL_ROOT"
|
|
||||||
else
|
|
||||||
nix flake update "$DEVSHELL_ROOT"
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
|
|
||||||
"get")
|
|
||||||
if [[ "$2" == "core" || "$2" == "community" ]]; then
|
|
||||||
nix flake new -t "github:divnix/devos/$2" "${3:-flk}"
|
|
||||||
else
|
|
||||||
echo "flk get (core|community) [DEST]"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
|
|
||||||
"iso")
|
|
||||||
nix build \
|
|
||||||
"$DEVSHELL_ROOT#nixosConfigurations.$2.config.system.build.iso" \
|
|
||||||
"${@:3}"
|
|
||||||
;;
|
|
||||||
|
|
||||||
"install")
|
|
||||||
sudo nixos-install --flake "$DEVSHELL_ROOT#$2" "${@:3}"
|
|
||||||
;;
|
|
||||||
|
|
||||||
"home")
|
|
||||||
ref="$DEVSHELL_ROOT/#homeConfigurations.$3@$2.activationPackage"
|
|
||||||
|
|
||||||
if [[ "$4" == "switch" ]]; then
|
|
||||||
nix build "$ref" && result/activate &&
|
|
||||||
unlink result
|
|
||||||
|
|
||||||
else
|
|
||||||
nix build "$ref" "${@:4}"
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
|
|
||||||
*)
|
|
||||||
sudo nixos-rebuild --flake "$DEVSHELL_ROOT#$1" "${@:2}"
|
|
||||||
;;
|
|
||||||
esac
|
|
|
@ -1,29 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
if git rev-parse --verify HEAD >/dev/null 2>&1
|
|
||||||
then
|
|
||||||
against=HEAD
|
|
||||||
else
|
|
||||||
# Initial commit: diff against an empty tree object
|
|
||||||
against=$(${git}/bin/git hash-object -t tree /dev/null)
|
|
||||||
fi
|
|
||||||
|
|
||||||
diff="git diff-index --name-only --cached $against --diff-filter d"
|
|
||||||
|
|
||||||
nix_files=($($diff -- '*.nix'))
|
|
||||||
all_files=($($diff))
|
|
||||||
|
|
||||||
# Format staged nix files.
|
|
||||||
if [[ -n "${nix_files[@]}" ]]; then
|
|
||||||
nixpkgs-fmt "${nix_files[@]}" \
|
|
||||||
&& git add "${nix_files[@]}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# check editorconfig
|
|
||||||
editorconfig-checker -- "${all_files[@]}"
|
|
||||||
if [[ $? != '0' ]]; then
|
|
||||||
printf "%b\n" \
|
|
||||||
"\nCode is not aligned with .editorconfig" \
|
|
||||||
"Review the output and commit your fixes" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
|
@ -1,83 +0,0 @@
|
||||||
{ pkgs-lib, pkgs, system, inputs, nixos, lib, ... }:
|
|
||||||
let
|
|
||||||
mkChecks = { hosts, nodes, homes ? { } }:
|
|
||||||
let
|
|
||||||
deployHosts = lib.filterAttrs
|
|
||||||
(n: _: hosts.${n}.config.nixpkgs.system == system)
|
|
||||||
nodes;
|
|
||||||
deployChecks = inputs.deploy.lib.${system}.deployChecks { nodes = deployHosts; };
|
|
||||||
tests =
|
|
||||||
{ libTests = libTests; }
|
|
||||||
// lib.optionalAttrs (deployHosts != { }) {
|
|
||||||
profilesTest = profilesTest (hosts.${(builtins.head (builtins.attrNames deployHosts))});
|
|
||||||
} // lib.mapAttrs (n: v: v.activationPackage) homes;
|
|
||||||
|
|
||||||
in
|
|
||||||
lib.recursiveUpdate tests deployChecks;
|
|
||||||
|
|
||||||
mkTest = host:
|
|
||||||
let
|
|
||||||
nixosTesting =
|
|
||||||
(import "${nixos}/nixos/lib/testing-python.nix" {
|
|
||||||
inherit system;
|
|
||||||
inherit (host.config.lib) specialArgs;
|
|
||||||
inherit pkgs;
|
|
||||||
extraConfigurations = [
|
|
||||||
host.config.lib.testModule
|
|
||||||
];
|
|
||||||
});
|
|
||||||
in
|
|
||||||
test:
|
|
||||||
let
|
|
||||||
loadedTest =
|
|
||||||
if builtins.typeOf test == "path"
|
|
||||||
then import test
|
|
||||||
else test;
|
|
||||||
calledTest =
|
|
||||||
if pkgs.lib.isFunction loadedTest
|
|
||||||
then pkgs.callPackage loadedTest { }
|
|
||||||
else loadedTest;
|
|
||||||
in
|
|
||||||
nixosTesting.makeTest calledTest;
|
|
||||||
|
|
||||||
profilesTest = host: mkTest host {
|
|
||||||
name = "profiles";
|
|
||||||
|
|
||||||
machine = { suites, ... }: {
|
|
||||||
imports = suites.allProfiles ++ suites.allUsers;
|
|
||||||
};
|
|
||||||
|
|
||||||
testScript = ''
|
|
||||||
${host.config.networking.hostName}.systemctl("is-system-running --wait")
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
libTests = pkgs.runCommandNoCC "devos-lib-tests"
|
|
||||||
{
|
|
||||||
buildInputs = [
|
|
||||||
pkgs.nix
|
|
||||||
(
|
|
||||||
let tests = pkgs-lib.callLibs ./lib.nix;
|
|
||||||
in
|
|
||||||
if tests == [ ]
|
|
||||||
then null
|
|
||||||
else throw (builtins.toJSON tests)
|
|
||||||
)
|
|
||||||
];
|
|
||||||
} ''
|
|
||||||
datadir="${pkgs.nix}/share"
|
|
||||||
export TEST_ROOT=$(pwd)/test-tmp
|
|
||||||
export NIX_BUILD_HOOK=
|
|
||||||
export NIX_CONF_DIR=$TEST_ROOT/etc
|
|
||||||
export NIX_LOCALSTATE_DIR=$TEST_ROOT/var
|
|
||||||
export NIX_LOG_DIR=$TEST_ROOT/var/log/nix
|
|
||||||
export NIX_STATE_DIR=$TEST_ROOT/var/nix
|
|
||||||
export NIX_STORE_DIR=$TEST_ROOT/store
|
|
||||||
export PAGER=cat
|
|
||||||
cacheDir=$TEST_ROOT/binary-cache
|
|
||||||
nix-store --init
|
|
||||||
|
|
||||||
touch $out
|
|
||||||
'';
|
|
||||||
in
|
|
||||||
{ inherit mkTest libTests profilesTest mkChecks; }
|
|
|
@ -1,93 +0,0 @@
|
||||||
{ pkgs, lib, dev, ... }:
|
|
||||||
with dev;
|
|
||||||
lib.runTests {
|
|
||||||
testConcatAttrs = {
|
|
||||||
expr = concatAttrs [{ foo = 1; } { bar = 2; } { baz = 3; }];
|
|
||||||
|
|
||||||
expected = { foo = 1; bar = 2; baz = 3; };
|
|
||||||
};
|
|
||||||
|
|
||||||
testGenAttrs' = {
|
|
||||||
expr = genAttrs'
|
|
||||||
[ "/foo/bar" "/baz/buzz" ]
|
|
||||||
(path: {
|
|
||||||
name = baseNameOf path;
|
|
||||||
value = "${path}/fizz";
|
|
||||||
});
|
|
||||||
|
|
||||||
expected = { bar = "/foo/bar/fizz"; buzz = "/baz/buzz/fizz"; };
|
|
||||||
};
|
|
||||||
|
|
||||||
testMapFilterAttrs = {
|
|
||||||
expr = mapFilterAttrs
|
|
||||||
(n: v: n == "foobar" && v == 1)
|
|
||||||
(n: v: lib.nameValuePair ("${n}bar") (v + 1))
|
|
||||||
{ foo = 0; bar = 2; };
|
|
||||||
|
|
||||||
expected = { foobar = 1; };
|
|
||||||
};
|
|
||||||
|
|
||||||
testPathsIn = {
|
|
||||||
expr = pathsIn (toString ./testPathsIn);
|
|
||||||
|
|
||||||
expected = map toString [
|
|
||||||
./testPathsIn/bar
|
|
||||||
./testPathsIn/baz
|
|
||||||
./testPathsIn/foo
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
testPathsToImportedAttrs = {
|
|
||||||
expr =
|
|
||||||
pathsToImportedAttrs [
|
|
||||||
(toString ./testPathsToImportedAttrs/dir)
|
|
||||||
./testPathsToImportedAttrs/foo.nix
|
|
||||||
./testPathsToImportedAttrs/bar.nix
|
|
||||||
./testPathsToImportedAttrs/t.nix
|
|
||||||
./testPathsToImportedAttrs/f.nix
|
|
||||||
];
|
|
||||||
|
|
||||||
expected = {
|
|
||||||
dir = { a = 5; };
|
|
||||||
foo = { bar = 1; };
|
|
||||||
bar = { foo = 2; };
|
|
||||||
t = true;
|
|
||||||
f = false;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
testRgxToString = lib.testAllTrue [
|
|
||||||
(rgxToString ".+x" "vxk" == "vx")
|
|
||||||
(rgxToString "^fo" "foo" == "fo")
|
|
||||||
(rgxToString "a?" "a" == "a")
|
|
||||||
(rgxToString "hat" "foohatbar" == "hat")
|
|
||||||
];
|
|
||||||
|
|
||||||
testSafeReadDir = {
|
|
||||||
expr = safeReadDir ./profiles // safeReadDir ./nonexistentdir;
|
|
||||||
expected = {
|
|
||||||
foo = "directory";
|
|
||||||
t = "directory";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
testSuites =
|
|
||||||
let
|
|
||||||
profiles = os.mkProfileAttrs (toString ./profiles);
|
|
||||||
users = "";
|
|
||||||
userProfiles = "";
|
|
||||||
suites = { profiles, ... }: {
|
|
||||||
system.bar = [ profiles.foo ];
|
|
||||||
};
|
|
||||||
in
|
|
||||||
{
|
|
||||||
expr = os.mkSuites { inherit profiles users userProfiles suites; };
|
|
||||||
expected = {
|
|
||||||
system = {
|
|
||||||
bar = [ profiles.foo.default ];
|
|
||||||
allProfiles = [ profiles.foo.default profiles.t.default ];
|
|
||||||
allUsers = [ ];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -1,3 +0,0 @@
|
||||||
{
|
|
||||||
bar = 5;
|
|
||||||
}
|
|
|
@ -1 +0,0 @@
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
{ foo = 2; }
|
|
|
@ -1 +0,0 @@
|
||||||
{ a = 5; }
|
|
|
@ -1 +0,0 @@
|
||||||
true && false
|
|
|
@ -1 +0,0 @@
|
||||||
{ bar = 1; }
|
|
|
@ -1 +0,0 @@
|
||||||
true || false
|
|
|
@ -1,20 +0,0 @@
|
||||||
{ lib, ... }:
|
|
||||||
{
|
|
||||||
# returns matching part of _regex_ _string_; null indicates failure.
|
|
||||||
rgxToString = regex: string:
|
|
||||||
let
|
|
||||||
match =
|
|
||||||
let
|
|
||||||
head = lib.substring 0 1 regex;
|
|
||||||
sec = lib.substring 1 2 regex;
|
|
||||||
in
|
|
||||||
if head == "^"
|
|
||||||
|| head == "."
|
|
||||||
|| (sec == "*" || sec == "+" || sec == "?")
|
|
||||||
then builtins.match "(${regex}).*" string
|
|
||||||
else builtins.match ".*(${regex}).*" string;
|
|
||||||
in
|
|
||||||
if lib.isList match
|
|
||||||
then lib.head match
|
|
||||||
else null;
|
|
||||||
}
|
|
30
modules/customBuilds.nix
Normal file
30
modules/customBuilds.nix
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
{ lib, self, diggaLib, config, modules, channel, ... }:
|
||||||
|
let
|
||||||
|
mkBuild = buildModule:
|
||||||
|
# TODO: get specialArgs as a module argument and drop builderArgs usage
|
||||||
|
channel.input.lib.nixosSystem (diggaLib.mergeAny config.lib.builderArgs {
|
||||||
|
modules = [ buildModule ];
|
||||||
|
});
|
||||||
|
in
|
||||||
|
{
|
||||||
|
system.build = {
|
||||||
|
iso = (mkBuild (diggaLib.modules.isoConfig {
|
||||||
|
inherit self;
|
||||||
|
inherit (self) inputs;
|
||||||
|
fullHostConfig = config;
|
||||||
|
})).config.system.build.isoImage;
|
||||||
|
|
||||||
|
homes = (mkBuild ({ config, ... }: {
|
||||||
|
home-manager.useUserPackages = lib.mkForce false;
|
||||||
|
home-manager.sharedModules = [
|
||||||
|
{
|
||||||
|
home.sessionVariables = {
|
||||||
|
inherit (config.environment.sessionVariables) NIX_PATH;
|
||||||
|
};
|
||||||
|
xdg.configFile."nix/registry.json".text =
|
||||||
|
config.environment.etc."nix/registry.json".text;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
})).config.home-manager.users;
|
||||||
|
};
|
||||||
|
}
|
28
overlays/overrides.nix
Normal file
28
overlays/overrides.nix
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
channels: final: prev: {
|
||||||
|
|
||||||
|
__dontExport = true; # overrides clutter up actual creations
|
||||||
|
|
||||||
|
inherit (channels.latest)
|
||||||
|
cachix
|
||||||
|
dhall
|
||||||
|
discord
|
||||||
|
element-desktop
|
||||||
|
manix
|
||||||
|
nixpkgs-fmt
|
||||||
|
qutebrowser
|
||||||
|
signal-desktop
|
||||||
|
starship;
|
||||||
|
|
||||||
|
|
||||||
|
haskellPackages = prev.haskellPackages.override {
|
||||||
|
overrides = hfinal: hprev:
|
||||||
|
let version = prev.lib.replaceChars [ "." ] [ "" ] prev.ghc.version;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
# same for haskell packages, matching ghc versions
|
||||||
|
inherit (channels.latest.haskell.packages."ghc${version}")
|
||||||
|
haskell-language-server;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
{ config, lib, pkgs, ... }:
|
{ self, config, lib, pkgs, ... }:
|
||||||
let inherit (lib) fileContents;
|
let inherit (lib) fileContents;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
@ -12,7 +12,6 @@ in
|
||||||
binutils
|
binutils
|
||||||
coreutils
|
coreutils
|
||||||
curl
|
curl
|
||||||
deploy-rs
|
|
||||||
direnv
|
direnv
|
||||||
dnsutils
|
dnsutils
|
||||||
dosfstools
|
dosfstools
|
||||||
|
@ -77,7 +76,7 @@ in
|
||||||
'';
|
'';
|
||||||
|
|
||||||
# fix nixos-option
|
# fix nixos-option
|
||||||
nixos-option = "nixos-option -I nixpkgs=${toString ../../lib/compat}";
|
nixos-option = "nixos-option -I nixpkgs=${self}/lib/compat";
|
||||||
|
|
||||||
# sudo
|
# sudo
|
||||||
s = ifSudo "sudo -E ";
|
s = ifSudo "sudo -E ";
|
||||||
|
|
Loading…
Reference in a new issue