870897a3e9
202: iso: avoid systemd service startup r=nrdxp a=blaggacao fixes #194 alternative to #197 # Manual Tests <details> <summary>was unrelated</summary> - [ ] `flk install NixOS --impure` correctly onto `/mnt` ❎ (looks like no profile is present) Issue: https://github.com/divnix/devos/issues/204 Upstream Issue: https://github.com/NixOS/nixpkgs/issues/116938 </details> - [x] acceptable build time / closure size ca 850MB (for a simple base OS) ✔️ - [x] local profile with `cage` service is disabled, that is: boots into terminal ✔️ - [x] success: air gapped / offline devshell enter ✔️ - [ ] failure: aire gapped target install: ← non blocking bonus item ❎ ```console $ flk install POS warning: you don't have internet access; disabling some network-dependent features building the flake in path:/iso/devos?narHash=sha265-... warning: you don't have internet access; disabling some network-dependent features error: unable to download 'https://api.github.com/repos/NixOS/nixpkgs/df8e3...': Couldn't resolve host name (6) ``` → detailed rationale in the commit messages ❤️ @Pacman99 for the excellent and detailed discussions in #197 and the may ideas, suggestions and code. Co-authored-by: David Arnold <dar@xoe.solutions> |
||
---|---|---|
.. | ||
devos | ||
attrs.nix | ||
default.nix | ||
lists.nix | ||
README.md | ||
strings.nix |
Lib
The lib directory mirrors the upstream concepts of nixpkgs:./lib
,
nixpkgs:./nixos/lib
and nixpkgs:./pkgs/pkgs-lib
,
but also occasionally nixpkgs:./pkgs/build-support
.
It comes with functions necesary to declutter devos
itself, but you are
welcome to extend it to your needs.
For example:
-
you want to add a library function that depends on some packages and use it throughout your devos environment: place it into
./lib
as if you would place it intonixpkgs:./pkgs/pkgs-lib
. -
you want to add library functions that don't depend on
pkgs
: place them into./lib
as if you would place them intonixpkgs:./lib
. -
need to try out a newish custom build support: place it here before upstreaming into
nixpkgs:./pkgs/build-support
. -
you want to reutilize certain module configuration functions or helpers: place them into
./lib
as if you would place them intonixpkgs:./nixos/lib
.
Once your library grows, we recoomend you start organizing them into subfolders
analogous nixpkgs
:
nixpkgs |
devos |
---|---|
./lib |
./lib |
./pkgs/pkgs-lib |
./lib/pkgs-lib |
./nixos/lib |
./lib/nixos-lib |
./pkgs/build-support |
./lib/pkgs-build |
Example
lib/nixos-lib/mkCustomI3BindSym/default.nix:
{ pkgs, writers, ... }:
{ name, cmd, workspace, baseKey }:
let
isWorkspaceEmpty = writers.writePython3 "is-workspace-empty" {
libraries = [ pkgs.python3Packages.i3ipc ];
} (builtins.readFile ./is-workspace-empty.py);
ws = builtins.toString workspace;
in
''
# ${name}
#bindsym ${baseKey}+${ws} workspace ${ws}; exec ${cmd}
bindsym ${baseKey}+${ws} workspace ${ws}; exec bash -c "${isWorkspaceEmpty} && ${cmd}"
''
lib/nixos-lib/mkCustomI3BindSym/is-workspace-empty.py:
# returns 0/1 if current workspace is empty/non-empty
import i3ipc
i3 = i3ipc.Connection()
tree = i3.get_tree()
def current_workspace():
return tree.find_focused().workspace()
if current_workspace().leaves():
print("Error current workspace is not empty")
exit(1)
exit(0)
lib/default.nix:
{ nixos, pkgs, ... }:
# ...
{
# ...
mkCustomI3BindSym = pkgs.callPackage ./nixos-lib/mkCustomI3BindSym { };
}