Skip to content

Commit 08a6145

Browse files
committed
[WIP] Big pile of changes to be amended next
1 parent f814c2d commit 08a6145

23 files changed

+404
-100
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ nixos.qcow2
33
result
44
result-*
55
*.elc
6+
*.pem

files/nix/rpi-image.nix

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{ nixpkgs, rootPath }:
1+
{ nixpkgs, rootPath, nixos-hardware }:
22

33
let
44
configuration =
@@ -7,6 +7,7 @@ let
77
{
88
imports = [
99
(modulesPath + "/installer/sd-card/sd-image-aarch64.nix")
10+
nixos-hardware.nixosModules.raspberry-pi-4
1011
];
1112

1213
networking = {

flake.lock

+33
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

+40-3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
nixos-2211-small.url = "github:NixOS/nixpkgs/nixos-22.11-small";
2828
nixos-2311.url = "github:NixOS/nixpkgs/nixos-23.11";
2929

30+
nixos-hardware.url = "github:NixOS/nixos-hardware";
31+
3032
deploy-rs = {
3133
url = "github:serokell/deploy-rs";
3234
inputs = {
@@ -444,6 +446,11 @@
444446
url = "github:numtide/nixpkgs-unfree";
445447
inputs.nixpkgs.follows = "nixpkgs";
446448
};
449+
450+
catppuccin-yazi = {
451+
url = "github:catppuccin/yazi";
452+
flake = false;
453+
};
447454
};
448455

449456
outputs =
@@ -527,6 +534,7 @@
527534
mkHome
528535
mkNixOnDroid
529536
mkNixos
537+
mkRaspiNixos
530538
mkDeploy
531539
mkDevenvJvmLang
532540
mkDevenvDeno
@@ -597,6 +605,15 @@
597605
];
598606
};
599607

608+
609+
/**
610+
Sample queries:
611+
nix-repl> :p nixOnDroidConfigurations.sams9.config.home-manager.config.home.username
612+
nix-repl> :p homeConfigurations."dani@maiziedemacchiato".config.home.username
613+
nix-repl> :p nixosConfigurations.DANIELKNB1.config.home-manager.users.nixos.home.username
614+
nix eval --json .#raspberries.twopi.config.system.build.sdImage --show-trace
615+
nix eval --json .#raspberries.twopi.config.system.build.toplevel --show-trace
616+
*/
600617
homeConfigurations = listToAttrs [
601618
/**
602619
calls `mkHome` as defined in ./flake/default.nix (`[system]` and `[name]` parameters) and ./flake/builders/mkHome.nix, latter the place where `extraSpecialArgs` would also go
@@ -611,9 +628,12 @@
611628

612629
nixosConfigurations = listToAttrs [
613630
(mkNixos "x86_64-linux" "DANIELKNB1")
614-
(mkNixos "aarch64-linux" "twopi")
615631
];
616632

633+
raspberries = listToAttrs [
634+
(mkRaspiNixos "aarch64-linux" "twopi")
635+
(mkRaspiNixos "x86_64-linux" "twopivm")
636+
];
617637
# Expose the necessary information in your flake so agenix-rekey
618638
# knows where it has too look for secrets and paths.
619639
#
@@ -882,7 +902,7 @@
882902
{
883903
aarch64-linux = {
884904
rpi-firmware = import ./files/nix/rpi-firmware.nix { inherit nixpkgs; };
885-
rpi-image = import ./files/nix/rpi-image.nix { inherit nixpkgs rootPath; };
905+
rpi-image = import ./files/nix/rpi-image.nix { inherit nixpkgs rootPath; inherit (inputs) nixos-hardware; };
886906
};
887907
armv7l-linux = {
888908
# TODO try https://github.com/n8henrie/nixos-btrfs-pi/blob/master/flake.nix
@@ -892,7 +912,24 @@
892912
run-in-vm = import ./files/nix/run-in-vm.nix { inherit nixpkgs rootPath; };
893913
};
894914

895-
x86_64-linux.installer-image = import ./files/nix/installer-image.nix { inherit nixpkgs; };
915+
x86_64-linux = {
916+
installer-image = import ./files/nix/installer-image.nix { inherit nixpkgs; };
917+
# https://discourse.nixos.org/t/get-qemu-guest-integration-when-running-nixos-rebuild-build-vm/22621
918+
# https://mattwidmann.net/notes/running-nixos-in-a-vm/
919+
# https://blog.yaymukund.com/posts/nixos-raspberry-pi-nixbuild-headless/
920+
# nix build --max-jobs 1 .#packages.x86_64-linux.demo-with-automatic-vm-integration
921+
demo-with-automatic-vm-integration = nixpkgs.legacyPackages.x86_64-linux.pkgs.writeShellApplication {
922+
name = "run-nixos-vm";
923+
runtimeInputs = [ nixpkgs.legacyPackages.x86_64-linux.pkgs.virt-viewer ];
924+
text = ''
925+
echo hi
926+
${self.raspberries.twopivm.config.system.build.vm}/bin/run-twopi-vm & PID_QEMU="$!"
927+
sleep 1 # I think some tools have an option to wait like -w
928+
remote-viewer spice://127.0.0.1:5930
929+
kill $PID_QEMU
930+
'';
931+
};
932+
};
896933
}
897934
(
898935
nixpkgs.lib.mapAttrsToList cachixDeployOutputNixos self.nixosConfigurations

flake/builders/mkHome.nix

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ inputs.home-manager.lib.homeManagerConfiguration {
5959
inputs.emacs-overlay.lib.${system}.emacsWithPackagesFromUsePackage;
6060

6161
homeDir =
62+
# should not break with raspberry as it concerns only non-nixos
6263
if isLinux && isAarch64 then
6364
"/data/data/com.termux.nix/files/home"
6465
else

flake/builders/mkRaspiNixos.nix

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
inputs,
3+
rootPath,
4+
system,
5+
pkgsFor,
6+
customLibFor,
7+
homeModulesFor,
8+
name,
9+
...
10+
}:
11+
let
12+
inherit (pkgsFor.${system}.stdenv) isLinux isAarch64;
13+
inherit (pkgsFor.${system}.lib) removeSuffix hasSuffix;
14+
in
15+
inputs.nixpkgs.lib.nixosSystem {
16+
inherit system;
17+
18+
/**
19+
see ./../../flake.nix attribute `specialArgs` and `flakeLib`
20+
21+
IDEA inject `specialArgs` there get from this functions (./mkNixos.nix) parameters and attach here via `// specialArgs`
22+
*/
23+
specialArgs = {
24+
inherit inputs rootPath;
25+
homeModules = homeModulesFor.${system};
26+
#image = true;
27+
};
28+
29+
modules = [
30+
/**
31+
anything in `specialArgs` should be available via i. e. ./../../hosts/DANIELKNB1/configuration.nix function's parameters set, i. e. `{ ..., unstable, ... }:` when `unstable =` declared in `specialArgs`
32+
*/
33+
"${rootPath}/hosts/${if hasSuffix "vm" name then (removeSuffix "vm" name) else name}/configuration.nix"
34+
"${rootPath}/hosts/${if hasSuffix "vm" name then (removeSuffix "vm" name) else name}/hardware-configuration.nix"
35+
36+
{
37+
_file = ./mkImage.nix;
38+
39+
custom.base.general.hostname = if hasSuffix "vm" name then (removeSuffix "vm" name) else name;
40+
41+
lib.custom = customLibFor.${system};
42+
43+
nixpkgs.pkgs = pkgsFor.${system};
44+
}
45+
] ++ customLibFor.${system}.listNixFilesRecursive "${rootPath}/nixos";
46+
}

flake/default.nix

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
inputs,
33
rootPath,
4-
forEachSystem
4+
forEachSystem,
55
}:
66

77
let
@@ -145,6 +145,7 @@ in
145145
mkNixOnDroid = simpleWrapper ./builders/mkNixOnDroid.nix;
146146
mkNixos = simpleWrapper ./builders/mkNixos.nix;
147147
mkDeploy = simpleWrapper ./builders/mkDeploy.nix;
148+
mkRaspiNixos = simpleWrapper ./builders/mkRaspiNixos.nix;
148149

149150
mkApp = wrapper ./builders/mkApp.nix;
150151
mkDevShellJdk = wrapper ./builders/mkDevShellJdk.nix;

flake/nixpkgs.nix

+7-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
system,
55
pkgsSet ? inputs.nixpkgs,
66
nixOnDroid ? false,
7+
# raspberry ? false,
78
config ? {
89
# FIXME https://discourse.nixos.org/t/unexpected-11h-build-after-auto-update/39907/9
910
allowAliases = false;
@@ -136,5 +137,10 @@ import pkgsSet {
136137
inputs.nix-on-droid.overlays.default
137138
# prevent uploads to remote builder, https://ryantm.github.io/nixpkgs/functions/prefer-remote-fetch
138139
(final: prev: prev.prefer-remote-fetch final prev)
139-
];
140+
] ++ # https://github.com/nix-community/nixos-generators/issues/266 TODO parameter raspberry analog nixOnDroid
141+
[ (final: prev: {
142+
makeModulesClosure = x:
143+
prev.makeModulesClosure (x // { allowMissing = true; });
144+
}) ]
145+
;
140146
}

home/base/general.nix

+1-4
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,7 @@ in
7676
# not inherit not same attr
7777
lightWeight = cfg.lightWeight;
7878
};
79-
shell.shellAliases = {
80-
nixbuild-shell = "nix run nixpkgs#rlwrap ssh eu.nixbuild.net shell";
81-
};
82-
};
79+
};
8380

8481
programs = {
8582
zoxide = {

home/base/non-nixos.nix

+5-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@ let
1313
concatStringsSep
1414
mkEnableOption
1515
mkIf
16+
mkMerge
1617
mkOption
18+
optional
1719
optionals
1820
types
21+
unique
1922
;
2023

2124
cfg = config.custom.base.non-nixos;
@@ -38,9 +41,8 @@ in
3841

3942
builders = mkOption {
4043
type = types.listOf types.str;
41-
default = [
42-
"ssh://eu.nixbuild.net aarch64-linux,armv7l-linux - 100 1 benchmark,big-parallel - -"
43-
];
44+
# DONE Make configurable the other way around in nixbuild dependent on this builders here, explainer https://gist.github.com/573/1ff0527f8b42b0123dc3a13bc523f487
45+
default = [];# ++ optional config.custom.programs.nixbuild.enable "ssh://[email protected] aarch64-linux,armv7l-linux /home/${config.home.username}/.ssh/my-nixbuild-key 100 2 benchmark,big-parallel - c3NoLWVkMjU1MTkgQUFBQUMzTnphQzFsWkRJMU5URTVBQUFBSVBJUUNaYzU0cG9KOHZxYXdkOFRyYU5yeVFlSm52SDFlTHBJRGdiaXF5bU0K";
4446
description = "Nix remote builders.";
4547
};
4648
};

home/programs/neovim.nix

+6-2
Original file line numberDiff line numberDiff line change
@@ -475,9 +475,9 @@ let
475475
autostart = true;
476476
};
477477

478-
nixd = {
478+
nixd = {
479479
# Nix LS
480-
enable = false; # FIXME re-enable when crashes on termux are fixed
480+
enable = true; # FIXME re-enable when crashes on termux are fixed
481481
settings =
482482
let
483483
flake = ''(builtins.getFlake "${inputs.self}")'';
@@ -820,6 +820,10 @@ in
820820
makeWrapper ${minimalPackage.outPath}/bin/nvim $out/bin/vi --argv0 nvim
821821
'')
822822
];
823+
824+
custom.programs.shell.shellAliases = {
825+
f2clip = ''vi '+execute "normal ggVG\"+y"' +wq'';
826+
};
823827
}
824828

825829
(mkIf (!cfg.lightWeight) {

home/programs/nixbuild.nix

+24-14
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ let
1212
mkMerge
1313
;
1414

15+
nixbuild-builder = lib.optionalString config.custom.base.non-nixos.enable "ssh-ng://[email protected] aarch64-linux,armv7l-linux ${config.home.homeDirectory}/.ssh/my-nixbuild-key 100 2 benchmark,big-parallel - c3NoLWVkMjU1MTkgQUFBQUMzTnphQzFsWkRJMU5URTVBQUFBSVBJUUNaYzU0cG9KOHZxYXdkOFRyYU5yeVFlSm52SDFlTHBJRGdiaXF5bU0K";
16+
1517
cfg = config.custom.programs.nixbuild;
1618
in
1719

18-
{
20+
{ # FIXME overlap with ../../home/base/non-nixos.nix
1921

2022
###### interface
2123

@@ -27,26 +29,34 @@ in
2729

2830
###### implementation
2931
config = mkIf cfg.enable (mkMerge [
30-
(mkIf (cfg.custom.base.non-nixos) {
31-
programs.ssh.extraConfig = ''
32-
Host eu.nixbuild.net
33-
PubkeyAcceptedKeyTypes ssh-ed25519
34-
ServerAliveInterval 60
35-
IPQoS throughput
36-
IdentityFile /root/.ssh/my-nixbuild-key
37-
'';
38-
39-
# custom.base.non-nixos.builders = [
40-
# "eu.nixbuild.net aarch64-linux - 100 1 benchmark big-parallel"
41-
# ];
32+
(mkIf (config.custom.base.non-nixos.enable) {
33+
programs.ssh.matchBlocks.nixbuild = lib.debug.traceIf (config.custom.base.non-nixos.builders != []) ''setting builder entry: ${builtins.toString nixbuild-builder}'' {
34+
hostname = "eu.nixbuild.net";
35+
user = "root";
36+
extraOptions = {
37+
"PubkeyAcceptedKeyTypes" = "ssh-ed25519";
38+
"IPQoS" = "throughput";
39+
};
40+
serverAliveInterval = 60;
41+
identitiesOnly = true;
42+
identityFile = "${config.home.homeDirectory}/.ssh/my-nixbuild-key";
43+
};
44+
45+
# explainer why lib.debug.traceIf (...) here would give infinite recursion: here, with potential workaround `mkMergeTopLevel` function https://gist.github.com/udf uses: https://gist.github.com/573/1ff0527f8b42b0123dc3a13bc523f487
46+
custom.base.non-nixos.builders = [ nixbuild-builder ];
4247
})
4348

4449
{
45-
home.packages = builtins.attrValues {
50+
home.packages = builtins.attrValues {
4651
inherit (pkgs)
4752
rlwrap
4853
;
4954
};
55+
56+
custom.programs.shell.shellAliases = {
57+
nixbuild-shell = "nix run nixpkgs#rlwrap ssh nixbuild shell";
58+
};
59+
5060
}
5161
]);
5262
}

home/programs/yazi.nix

+3
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ in
6565
}
6666
];
6767
};
68+
69+
theme = builtins.fromTOML (builtins.readFile "${inputs.catppuccin-yazi}/themes/latte/catppuccin-latte-lavender.toml");
70+
6871
# https://yazi-rs.github.io/docs/resources
6972
# https://sourcegraph.com/search?q=context:global+file:%5E*yazi.toml%24+content:zathura&patternType=standard&sm=1
7073
settings = {

0 commit comments

Comments
 (0)