Skip to content

Commit

Permalink
Add iso
Browse files Browse the repository at this point in the history
  • Loading branch information
DashieTM committed Aug 31, 2024
1 parent 4123f8c commit 34d6f22
Show file tree
Hide file tree
Showing 13 changed files with 153 additions and 61 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -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/

3 changes: 2 additions & 1 deletion base/common_hardware.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
pkgs,
config,
lib,
hostName,
modulesPath,
...
}:
Expand Down Expand Up @@ -47,7 +48,7 @@ in
networking = {
useDHCP = lib.mkDefault true;
networkmanager.enable = true;
hostName = config.conf.hostname;
hostName = hostName;
};

# Set your time zone.
Expand Down
2 changes: 1 addition & 1 deletion docs/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
15 changes: 6 additions & 9 deletions docs/src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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 = {
Expand All @@ -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";
Expand Down Expand Up @@ -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"
];
Expand Down
2 changes: 1 addition & 1 deletion example/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
outputs =
{ ... }@inputs:
{
nixosConfigurations = (inputs.dashNix.dashNixLib.build_systems [ "example" ] ./.);
nixosConfigurations = (inputs.dashNix.dashNixLib.build_systems ./.);
};

nixConfig = {
Expand Down
5 changes: 2 additions & 3 deletions example/hosts/example/configuration.nix
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{ config, ... }:
{
# variables for system
# TODO important changes
Expand All @@ -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";
Expand Down Expand Up @@ -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"
];
Expand Down
File renamed without changes.
File renamed without changes.
8 changes: 6 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
};

outputs =
{ ... }@inputs:
{ self, ... }@inputs:
let
stable = import inputs.stable {
system = "x86_64-linux";
Expand All @@ -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;
Expand All @@ -77,6 +80,7 @@
stablePkgs = stable;
unstablePkgs = pkgs;
modules = ./modules;
iso = dashNixLib.buildIso.config.system.build.isoImage;
};

nixConfig = {
Expand Down
50 changes: 50 additions & 0 deletions iso/configuration.nix
Original file line number Diff line number Diff line change
@@ -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";
}
];
};
}
88 changes: 54 additions & 34 deletions lib/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
inputs,
pkgs,
self,
lib,
additionalMods ? {
nixos = [ ];
home = [ ];
Expand Down Expand Up @@ -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
Expand All @@ -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 ];
};
}
9 changes: 0 additions & 9 deletions modules/conf.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion result

0 comments on commit 34d6f22

Please sign in to comment.