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,
config,
lib,
hostName,
modulesPath,
...
}:
@ -47,7 +48,7 @@ in
networking = {
useDHCP = lib.mkDefault true;
networkmanager.enable = true;
hostName = config.conf.hostname;
hostName = hostName;
};
# Set your time zone.

View file

@ -14,7 +14,7 @@ let
summaryAppend = name: ''
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}; };
conf = makeOptionsDoc system.conf;
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:
```nix
nixosConfigurations = (inputs.dashNix.dashNixLib.build_systems [
"system1"
"system2"
"system3"
] ./.);
nixosConfigurations = (inputs.dashNix.dashNixLib.build_systems ./.);
```
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.
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):
```nix
{
{config, ...}: {
# variables for system
# TODO important changes
conf = {
@ -64,8 +63,6 @@ Here is a minimal required configuration.nix (the TODOs mention a required chang
monitor = "YOURMONITOR";
# your username
username = "YOURNAME";
# the name of your system
hostname = "YOURNAME";
# TODO only needed when you use intel -> amd is default
# cpu = "intel";
locale = "something.UTF-8";
@ -100,7 +97,7 @@ Here is a minimal required configuration.nix (the TODOs mention a required chang
hyprland.monitor = [
# default
# TODO change this to your resolution
"DP-1,1920x1080@144,0x0,1"
"${config.conf.monitor},1920x1080@144,0x0,1"
# all others
",highrr,auto,1"
];

View file

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

View file

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

View file

@ -49,7 +49,7 @@
};
outputs =
{ ... }@inputs:
{ self, ... }@inputs:
let
stable = import inputs.stable {
system = "x86_64-linux";
@ -67,7 +67,10 @@
};
in
rec {
dashNixLib = import ./lib { inherit inputs pkgs; };
dashNixLib = import ./lib {
inherit self inputs pkgs;
lib = inputs.nixpkgs.lib;
};
docs = import ./docs {
inherit inputs pkgs;
lib = inputs.nixpkgs.lib;
@ -77,6 +80,7 @@
stablePkgs = stable;
unstablePkgs = pkgs;
modules = ./modules;
iso = dashNixLib.buildIso.config.system.build.isoImage;
};
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,
pkgs,
self,
lib,
additionalMods ? {
nixos = [ ];
home = [ ];
@ -42,12 +44,6 @@
The second parameter is the root of your configuration, which should be ./. in most cases.
# Inputs
`systems`
: a list of strings with hostnames
`root`
: 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 =
systems: root:
root:
builtins.listToAttrs (
map (name: {
name = name;
value =
let
mod = root + /hosts/${name}/configuration.nix;
additionalNixosConfig = root + /hosts/${name}/hardware.nix;
additionalHomeConfig = root + /hosts/${name}/home.nix;
in
inputs.nixpkgs.lib.nixosSystem {
specialArgs = {
inherit
inputs
pkgs
mod
additionalHomeConfig
root
;
homeMods = mods.home;
additionalHomeMods = additionalMods.home;
map
(name: {
name = name;
value =
let
mod = root + /hosts/${name}/configuration.nix;
additionalNixosConfig = root + /hosts/${name}/hardware.nix;
additionalHomeConfig = root + /hosts/${name}/home.nix;
in
inputs.nixpkgs.lib.nixosSystem {
specialArgs = {
inherit
self
inputs
pkgs
mod
additionalHomeConfig
root
;
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
++ additionalMods.nixos
++ inputs.nixpkgs.lib.optional (builtins.pathExists additionalNixosConfig) additionalNixosConfig
++ inputs.nixpkgs.lib.optional (builtins.pathExists mod) mod;
};
}) systems
})
(
lib.lists.remove "" (
lib.attrsets.mapAttrsToList (name: fType: if fType == "directory" then name else "") (
builtins.readDir (root + /hosts)
)
)
)
);
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 {
default = "dashie";
example = "pingpang";

2
result
View file

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