-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4526021
commit 3ee0836
Showing
6 changed files
with
191 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
with import <nixpkgs> { | ||
twith import <nixpkgs> { | ||
crossSystem.system = "aarch64-linux"; | ||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#+Title: Building a module abstraction | ||
#+SETUPFILE: ../../reveal.setup | ||
|
||
** home-manager | ||
|
||
\\ | ||
|
||
+ https://github.com/nix-community/home-manager | ||
+ ~nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager~ | ||
+ ~nix-channel --add https://github.com/nix-community/home-manager/archive/release-22.05.tar.gz home-manager~ | ||
+ ~nix-shell '<home-manager>' -A install~ | ||
|
||
** A lot of modules generate configuration | ||
|
||
\\ | ||
|
||
+ Pick a random config file (in INI, json, or yml format) from /etc | ||
on your computer | ||
+ You can generate files in your home directory with home-manager | ||
+ Create a custom module to generate it | ||
+ ~lib.generators~ can help generate various file formats | ||
+ ~lib.generators.toJSON { } { foo = 1; }~ results in ~{ "foo": 1 }~ | ||
|
||
** | ||
|
||
\\ | ||
|
||
#+BEGIN_SRC nix | ||
{ lib, config, ... }: | ||
with lib; # incule lib to cut down on boilerplate | ||
let cg = config.services.my-config-generator; | ||
in | ||
{ | ||
options.services.my-config-generator = { | ||
enable = mkEnableOption "Enable config generator"; | ||
|
||
etcName = mkOption { type = types.path; }; | ||
|
||
default = { | ||
type = types.listOf (submodule { | ||
options = { | ||
type = lib.mkOption { type = lib.str; }; | ||
}; | ||
}); | ||
}; | ||
|
||
config = lib.mkIf cg.enable { | ||
environment.etc."${cg.etcName}".text = /* generate file here */ | ||
}; | ||
}; | ||
} | ||
#+END_SRC | ||
|
||
** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters