Skip to content

feature: installer image #603

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
parts.lib.mkFlake {inherit inputs;} {
systems = ["x86_64-linux" "aarch64-linux" "aarch64-darwin"];

debug = true;

_module.args.npins = import ./npins;

imports = [
Expand All @@ -21,6 +23,50 @@
./packages
];

perSystem = {
pkgs,
self',
...
}: {
apps.installer.program = let
isoPath = "iso/${self'.packages.installer-iso.isoName}";
in
pkgs.writeShellScriptBin "installer" ''
image=disk.qcow2
isoPath=$(mktemp -d)/result
isoFull=$isoPath/${isoPath}

test -f $image || ${pkgs.qemu}/bin/qemu-img create -f qcow2 $image 50G

nom build .#installer-iso -o $isoPath

${pkgs.qemu}/bin/qemu-system-x86_64 \
-drive file=$image,if=virtio \
-cdrom $isoPath/${isoPath} \
-m 8G \
-smp 2 \
-enable-kvm \
-netdev user,id=net0 \
-device virtio-net,netdev=net0 \
-device virtio-vga \
-bios ${pkgs.OVMF.fd}/FV/OVMF.fd

du -h $isoFull
rm -f $isoPath
'';

apps.awesome-preview.program = let
rc_lua = pkgs.runCommandNoCC "awesomerc.lua" {} ''
substitute ${./packages/installer/awesomerc.lua} $out \
--subst-var-by FILE_PATH_WALLPAPER ${./packages/installer/nix-glow-black.png} \
--subst-var-by NIX_FLAKE_SVG ${./packages/installer/nix-flake.svg}
'';
in
pkgs.writeShellScriptBin "awesome-preview" ''
${pkgs.xorg.xorgserver}/bin/Xephyr :5 & sleep 1 ; DISPLAY=:5 ${self'.packages.awesome}/bin/awesome --config ${rc_lua}
'';
};

flake = {
mixedModules = import ./mixed inputs;

Expand Down
12 changes: 12 additions & 0 deletions npins/sources.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
{
"pins": {
"awesome": {
"type": "Git",
"repository": {
"type": "GitHub",
"owner": "awesomewm",
"repo": "awesome"
},
"branch": "master",
"revision": "8b1f8958b46b3e75618bc822d512bb4d449a89aa",
"url": "https://github.com/awesomewm/awesome/archive/8b1f8958b46b3e75618bc822d512bb4d449a89aa.tar.gz",
"hash": "0a140ixasiyzyr6axd5akjcgdgx58pn2kqdgy9ag6hczhpf7jrk4"
},
"fzf-tab": {
"type": "Git",
"repository": {
Expand Down
29 changes: 28 additions & 1 deletion packages/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{inputs, ...}: {
{
inputs,
npins,
...
}: {
perSystem = {
system,
pkgs,
Expand All @@ -13,14 +17,37 @@
config.allowUnfree = true;
config.google-chrome.enableWideVine = true;
};

awesome = pkgs.awesome.overrideAttrs (oa: {
version = npins.awesome.revision;
src = npins.awesome;

patches = [];

postPatch = ''
patchShebangs tests/examples/_postprocess.lua
'';
});
in {
packages = lib.mkMerge [
{
installer-iso =
(upkgs.callPackage ./installer {
inherit (inputs.nixpkgs.lib) nixosSystem;
inherit npins;
inherit (inputs) nvim;
})
.config
.system
.build
.isoImage;

advcp = upkgs.callPackage ./advcp {};
"rofi/unicode" = upkgs.callPackage ./rofi-unicode {};
}
(lib.mkIf pkgs.stdenv.isLinux {
inherit (inputs'.switcher.packages) switcher;
inherit awesome;
})
(lib.mkIf (system == "x86_64-linux") {
inherit (chromePkgs) google-chrome;
Expand Down
47 changes: 47 additions & 0 deletions packages/installer/awesome.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
lib,
pkgs,
npins,
...
}: let
rc_lua = pkgs.runCommandNoCC "awesomerc.lua" {} ''
substitute ${./awesomerc.lua} $out \
--subst-var-by FILE_PATH_WALLPAPER ${./nix-glow-black.png} \
--subst-var-by TERMINAL_ICON_SVG ${./icons/terminal.svg} \
--subst-var-by GLOBE_ICON_SVG ${./icons/globe.svg} \
--subst-var-by PARTED_ICON_SVG ${./icons/parted.svg} \
--subst-var-by NIX_FLAKE_SVG ${./icons/nix-flake.svg}
'';

menu_entries = pkgs.writeText "menu_entries.lua" ''
return {
{ "NixOS Manual", "nixos-help", "${./icons/manual.svg}" },
{ "GParted", "${lib.getExe pkgs.gparted}", "${./icons/parted.svg}" },
{ "Reboot", "reboot", "${./icons/reboot.svg}" },
{ "Power Off", "poweroff", "${./icons/power-off.svg}" },
}
'';

awesome = pkgs.awesome.overrideAttrs (oa: {
version = npins.awesome.revision;
src = npins.awesome;

patches = [];

postPatch = ''
patchShebangs tests/examples/_postprocess.lua
'';
});
in {
_file = ./awesome.nix;

services.xserver.windowManager.awesome = {
enable = true;
package = awesome;
};

systemd.user.tmpfiles.rules = [
"L+ %h/.config/awesome/rc.lua - - - - ${rc_lua}"
"L+ %h/.config/awesome/menu_entries.lua - - - - ${menu_entries}"
];
}
Loading
Loading