This commit is contained in:
DashieTM 2024-08-31 14:29:16 +02:00
parent 4123f8ccac
commit 34d6f22b61
13 changed files with 153 additions and 61 deletions

30
.github/workflows/release.yaml vendored Normal file
View file

@ -0,0 +1,30 @@
# by https://github.com/danth/stylix/blob/master/.github/workflows/docs.yml
name: Release
on:
release:
types: [created]
jobs:
build:
name: Release
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
extra-conf: |
extra-experimental-features = nix-command flakes
- name: Set up cache
uses: DeterminateSystems/magic-nix-cache-action@main
- name: Build ISO
run: nix build github:${{ github.repository }}/${{ github.sha }}#iso
- name: Prepare ISO for upload
run: |
cp -r --dereference --no-preserve=mode,ownership result/ public/
- name: upload ISO
uses: softprops/action-gh-release@v1
with:
path: path/

View file

@ -2,6 +2,7 @@
pkgs, pkgs,
config, config,
lib, lib,
hostName,
modulesPath, modulesPath,
... ...
}: }:
@ -47,7 +48,7 @@ in
networking = { networking = {
useDHCP = lib.mkDefault true; useDHCP = lib.mkDefault true;
networkmanager.enable = true; networkmanager.enable = true;
hostName = config.conf.hostname; hostName = hostName;
}; };
# Set your time zone. # Set your time zone.

View file

@ -14,7 +14,7 @@ let
summaryAppend = name: '' summaryAppend = name: ''
echo "- [${name}](${name}.md)" >> src/SUMMARY.md echo "- [${name}](${name}.md)" >> src/SUMMARY.md
''; '';
system = (build_systems [ "example" ] ../example/.)."example".options; system = (build_systems ../example/.)."example".options;
makeOptionsDocPrograms = name: pkgs.nixosOptionsDoc { options = system.mods.${name}; }; makeOptionsDocPrograms = name: pkgs.nixosOptionsDoc { options = system.mods.${name}; };
conf = makeOptionsDoc system.conf; conf = makeOptionsDoc system.conf;
paths = builtins.readDir ../modules/programs; paths = builtins.readDir ../modules/programs;

View file

@ -26,13 +26,12 @@ dashNix = {
You can then configure your systems in your flake outputs with a provided library command: You can then configure your systems in your flake outputs with a provided library command:
```nix ```nix
nixosConfigurations = (inputs.dashNix.dashNixLib.build_systems [ nixosConfigurations = (inputs.dashNix.dashNixLib.build_systems ./.);
"system1"
"system2"
"system3"
] ./.);
``` ```
The paremeter specifies where your hosts directory will be placed, in said directory you can then create a directory for each system.
Note, the name of the systems directory is also its hostname.
In order for your configuration to work, you are required to at least provide a single config file with a further config file being optional for custom configuration. In order for your configuration to work, you are required to at least provide a single config file with a further config file being optional for custom configuration.
The hardware.nix specifies additional NixOS configuration, while home.nix specifies additional home-manager configuration. (both optional) The hardware.nix specifies additional NixOS configuration, while home.nix specifies additional home-manager configuration. (both optional)
@ -55,7 +54,7 @@ The hardware.nix specifies additional NixOS configuration, while home.nix specif
Here is a minimal required configuration.nix (the TODOs mention a required change): Here is a minimal required configuration.nix (the TODOs mention a required change):
```nix ```nix
{ {config, ...}: {
# variables for system # variables for system
# TODO important changes # TODO important changes
conf = { conf = {
@ -64,8 +63,6 @@ Here is a minimal required configuration.nix (the TODOs mention a required chang
monitor = "YOURMONITOR"; monitor = "YOURMONITOR";
# your username # your username
username = "YOURNAME"; username = "YOURNAME";
# the name of your system
hostname = "YOURNAME";
# TODO only needed when you use intel -> amd is default # TODO only needed when you use intel -> amd is default
# cpu = "intel"; # cpu = "intel";
locale = "something.UTF-8"; locale = "something.UTF-8";
@ -100,7 +97,7 @@ Here is a minimal required configuration.nix (the TODOs mention a required chang
hyprland.monitor = [ hyprland.monitor = [
# default # default
# TODO change this to your resolution # TODO change this to your resolution
"DP-1,1920x1080@144,0x0,1" "${config.conf.monitor},1920x1080@144,0x0,1"
# all others # all others
",highrr,auto,1" ",highrr,auto,1"
]; ];

View file

@ -24,7 +24,7 @@
outputs = outputs =
{ ... }@inputs: { ... }@inputs:
{ {
nixosConfigurations = (inputs.dashNix.dashNixLib.build_systems [ "example" ] ./.); nixosConfigurations = (inputs.dashNix.dashNixLib.build_systems ./.);
}; };
nixConfig = { nixConfig = {

View file

@ -1,3 +1,4 @@
{ config, ... }:
{ {
# variables for system # variables for system
# TODO important changes # TODO important changes
@ -7,8 +8,6 @@
monitor = "YOURMONITOR"; monitor = "YOURMONITOR";
# your username # your username
username = "YOURNAME"; username = "YOURNAME";
# the name of your system
hostname = "YOURNAME";
# TODO only needed when you use intel -> amd is default # TODO only needed when you use intel -> amd is default
# cpu = "intel"; # cpu = "intel";
locale = "something.UTF-8"; locale = "something.UTF-8";
@ -52,7 +51,7 @@
hyprland.monitor = [ hyprland.monitor = [
# default # default
# TODO change this to your resolution # TODO change this to your resolution
"DP-1,1920x1080@144,0x0,1" "${config.conf.monitor},1920x1080@144,0x0,1"
# all others # all others
",highrr,auto,1" ",highrr,auto,1"
]; ];

View file

@ -49,7 +49,7 @@
}; };
outputs = outputs =
{ ... }@inputs: { self, ... }@inputs:
let let
stable = import inputs.stable { stable = import inputs.stable {
system = "x86_64-linux"; system = "x86_64-linux";
@ -67,7 +67,10 @@
}; };
in in
rec { rec {
dashNixLib = import ./lib { inherit inputs pkgs; }; dashNixLib = import ./lib {
inherit self inputs pkgs;
lib = inputs.nixpkgs.lib;
};
docs = import ./docs { docs = import ./docs {
inherit inputs pkgs; inherit inputs pkgs;
lib = inputs.nixpkgs.lib; lib = inputs.nixpkgs.lib;
@ -77,6 +80,7 @@
stablePkgs = stable; stablePkgs = stable;
unstablePkgs = pkgs; unstablePkgs = pkgs;
modules = ./modules; modules = ./modules;
iso = dashNixLib.buildIso.config.system.build.isoImage;
}; };
nixConfig = { nixConfig = {

50
iso/configuration.nix Normal file
View file

@ -0,0 +1,50 @@
{
pkgs,
lib,
modulesPath,
self,
...
}:
{
imports = [ "${modulesPath}/installer/cd-dvd/installation-cd-minimal.nix" ];
nixpkgs.hostPlatform = {
system = "x86_64-linux";
};
environment.systemPackages = with pkgs; [
neovim
disko
git
vesktop
vscodium
firefox
kitty
];
networking = {
wireless.enable = false;
networkmanager.enable = true;
};
services.greetd = {
enable = true;
settings = {
initial_session = {
command = "${pkgs.hyprland}/bin/Hyprland";
user = "nixos";
};
};
};
isoImage = {
isoName = lib.mkForce "DashNix.iso";
makeEfiBootable = true;
makeUsbBootable = true;
contents = [
{
source = "${self}/example";
target = "example-config";
}
];
};
}

View file

@ -1,6 +1,8 @@
{ {
inputs, inputs,
pkgs, pkgs,
self,
lib,
additionalMods ? { additionalMods ? {
nixos = [ ]; nixos = [ ];
home = [ ]; home = [ ];
@ -42,12 +44,6 @@
The second parameter is the root of your configuration, which should be ./. in most cases. The second parameter is the root of your configuration, which should be ./. in most cases.
# Inputs
`systems`
: a list of strings with hostnames
`root` `root`
: the root path of your configuration : the root path of your configuration
@ -60,36 +56,60 @@
``` ```
::: :::
*/ */
# let
# paths = builtins.readDir ;
# names = lib.lists.remove "default" (
# map (name: lib.strings.removeSuffix ".nix" name) (lib.attrsets.mapAttrsToList (name: _: name) paths)
# );
# in
build_systems = build_systems =
systems: root: root:
builtins.listToAttrs ( builtins.listToAttrs (
map (name: { map
name = name; (name: {
value = name = name;
let value =
mod = root + /hosts/${name}/configuration.nix; let
additionalNixosConfig = root + /hosts/${name}/hardware.nix; mod = root + /hosts/${name}/configuration.nix;
additionalHomeConfig = root + /hosts/${name}/home.nix; additionalNixosConfig = root + /hosts/${name}/hardware.nix;
in additionalHomeConfig = root + /hosts/${name}/home.nix;
inputs.nixpkgs.lib.nixosSystem { in
specialArgs = { inputs.nixpkgs.lib.nixosSystem {
inherit specialArgs = {
inputs inherit
pkgs self
mod inputs
additionalHomeConfig pkgs
root mod
; additionalHomeConfig
homeMods = mods.home; root
additionalHomeMods = additionalMods.home; ;
hostName = name;
homeMods = mods.home;
additionalHomeMods = additionalMods.home;
};
modules =
[ mod ]
++ mods.nixos
++ additionalMods.nixos
++ inputs.nixpkgs.lib.optional (builtins.pathExists additionalNixosConfig) additionalNixosConfig
++ inputs.nixpkgs.lib.optional (builtins.pathExists mod) mod;
}; };
modules = })
[ mod ] (
++ mods.nixos lib.lists.remove "" (
++ additionalMods.nixos lib.attrsets.mapAttrsToList (name: fType: if fType == "directory" then name else "") (
++ inputs.nixpkgs.lib.optional (builtins.pathExists additionalNixosConfig) additionalNixosConfig builtins.readDir (root + /hosts)
++ inputs.nixpkgs.lib.optional (builtins.pathExists mod) mod; )
}; )
}) systems )
); );
buildIso = inputs.nixpkgs.lib.nixosSystem {
specialArgs = {
inherit self inputs pkgs;
};
modules = [ ../iso/configuration.nix ];
};
} }

View file

@ -103,15 +103,6 @@
''; '';
}; };
hostname = lib.mkOption {
default = "nixos";
example = "spaceship";
type = lib.types.str;
description = ''
The name of the system
'';
};
username = lib.mkOption { username = lib.mkOption {
default = "dashie"; default = "dashie";
example = "pingpang"; example = "pingpang";

2
result
View file

@ -1 +1 @@
/nix/store/3y1kplrb4rnks5hpb3n9c0r3x5x3lw54-dashNix-book /nix/store/9snhsj18w6vyi4f25sq93az859yigcdp-DashNix.iso