From 29359bf62e26f7a4139ee778d5cf8aaae5b445b1 Mon Sep 17 00:00:00 2001 From: Frantisek Bohacek Date: Wed, 5 Jun 2024 09:31:36 +0200 Subject: [PATCH] feat: add gnome iso installatiom image config --- flake.nix | 5 +++ nixos/isos/common/default.nix | 50 +++++++++++++++++++++++++++++ nixos/isos/common/emacs.nix | 13 ++++++++ nixos/isos/common/shell-apps.nix | 30 +++++++++++++++++ nixos/isos/common/ssh.nix | 24 ++++++++++++++ nixos/isos/common/users.nix | 22 +++++++++++++ nixos/isos/common/vim.nix | 53 +++++++++++++++++++++++++++++++ nixos/isos/default.nix | 34 ++++++++++++++++++++ nixos/isos/gnome-installation.nix | 8 +++++ 9 files changed, 239 insertions(+) create mode 100644 nixos/isos/common/default.nix create mode 100644 nixos/isos/common/emacs.nix create mode 100644 nixos/isos/common/shell-apps.nix create mode 100644 nixos/isos/common/ssh.nix create mode 100644 nixos/isos/common/users.nix create mode 100644 nixos/isos/common/vim.nix create mode 100644 nixos/isos/default.nix create mode 100644 nixos/isos/gnome-installation.nix diff --git a/flake.nix b/flake.nix index 5a2bea7..945a43f 100644 --- a/flake.nix +++ b/flake.nix @@ -71,6 +71,11 @@ dwlb = pkgs.callPackage ./pkgs/dwlb.nix {}; }; + installIsos = import ./nixos/isos { + inherit (nixpkgs-stable) lib; + inherit inputs; + }; + devShells.x86_64-linux.default = pkgs.mkShell { packages = [ pkgs.nil diff --git a/nixos/isos/common/default.nix b/nixos/isos/common/default.nix new file mode 100644 index 0000000..5837ee0 --- /dev/null +++ b/nixos/isos/common/default.nix @@ -0,0 +1,50 @@ +{ config, pkgs, lib, ... }: + +{ + imports = [ + ./users.nix + ./ssh.nix + ./vim.nix + ./emacs.nix + ./shell-apps.nix + ]; + + isoImage.squashfsCompression = "zstd -Xcompression-level 6"; + + fonts.packages = [ + (pkgs.nerdfonts.override { + fonts = [ "FiraCode" ]; + }) + ]; + + environment.systemPackages = [ + pkgs.foot + ]; + + environment.variables = { + SELF = config.deps-inject.inputs.self; + }; + + nix = { + settings = { + flake-registry = ""; + experimental-features = [ "nix-command" "flakes" ]; + }; + + registry = lib.mkMerge [ + (lib.mapAttrs (n: input: { + flake = input; + }) config.deps-inject.inputs) + + { + nixpkgs = lib.mkForce { + flake = config.deps-inject.inputs.nixpkgs-stable; + }; + } + ]; + + nixPath = [ + "nixpkgs=flake:nixpkgs" + ]; + }; +} diff --git a/nixos/isos/common/emacs.nix b/nixos/isos/common/emacs.nix new file mode 100644 index 0000000..437944e --- /dev/null +++ b/nixos/isos/common/emacs.nix @@ -0,0 +1,13 @@ +{ lib, pkgs, ... }: + +{ + environment.systemPackages = [ + ((pkgs.emacs.override { + withNativeCompilation = false; + }).pkgs.withPackages(epkgs: [ + epkgs.vterm + epkgs.sqlite + epkgs.treesit-grammars.with-all-grammars + ])) + ]; +} diff --git a/nixos/isos/common/shell-apps.nix b/nixos/isos/common/shell-apps.nix new file mode 100644 index 0000000..558e2a4 --- /dev/null +++ b/nixos/isos/common/shell-apps.nix @@ -0,0 +1,30 @@ +{ pkgs, config, ... }: + +{ + environment.systemPackages = [ + # (pkgs.writeShellApplication "git-clone-nixos-config" { buildInputs = [ pkgs.git ]; } '' + # git clone https://github.com/Rutherther/nixos-config + # mkdir -p nixos-config/nixos/hosts/$1 + # nixos-generate-config --dir nixos-config/nixos/hosts/$1 --root /mnt + # '') + + (pkgs.writeShellApplication { + name = "git-clone-nixos-config"; + text = '' + git clone https://github.com/Rutherther/nixos-config + ''; + }) + (pkgs.writeShellApplication { + name = "copy-self"; + text = '' + cp -r ${config.deps-inject.inputs.self} self + ''; + }) + (pkgs.writeShellApplication { + name = "link-self"; + text = '' + ln -s ${config.deps-inject.inputs.self} self + ''; + }) + ]; +} diff --git a/nixos/isos/common/ssh.nix b/nixos/isos/common/ssh.nix new file mode 100644 index 0000000..7abf62c --- /dev/null +++ b/nixos/isos/common/ssh.nix @@ -0,0 +1,24 @@ +{ config, lib, pkgs, ... }: + +let + sshKeys = [ + # ThinkPad + "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQD0mhvKW3dgLTGLGMgGdMgUFz14F16pRzSAH7IU/OssnYXmi+TlkXLakHtmNWLdb6IEEjS2od0iDW4I71awJjL/VqRSBBt/1t6ndM6M79pD6feU9uYaPMB20ORyZh5D+1zjWX4cFVlcfCQ2bUyV0D+VRoDrN/YWFhPU0XNMZjatqN8JNKljM0hwWt9OPuQdlwG5KnrbDPUn8gf6kZtfVWRamDrLLMKsGBeGw4oZVJLAPYJlaYps15VuySTw114n6/L16qpH/rUgDc5QFyrmtIE+l5wd5QteH489eG+8gAZfsbYj+pihek09rHch318ecsLYz/DxotB71BXsQH7nb0NPHk1VI8L6//meoCXNJc4Itbg7Jh2Oo/bDfYX9IyPEw2TRa3P+rbEO9N4vMxCgX+TuHNX/mTk0OFpJVu8AAwMlF2lalI8fpBKospP5PFoyIgrW7ab5dkQRGDTk+Bw1ed4KXMKl6RJejvDPuOAmpeOlosinz6OPj/rbR9hR48makxk= ruther@nixos" + # Phone + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIbHBbRaxwfOIyYYL6caWx8Afre8R+GRIgbX/zSGNmMq ruther@nord2-phone" + # Server + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGE9SGfSVF61WEiPwJg7VR+hWCYwCERX59xIcIF/TJlg ruther@pallium" + ]; +in { + services.openssh = { + enable = true; + settings = { + PermitEmptyPasswords = false; + }; + }; + + users.users = + (lib.genAttrs config.usersList (name: { + openssh.authorizedKeys.keys = sshKeys; + })); +} diff --git a/nixos/isos/common/users.nix b/nixos/isos/common/users.nix new file mode 100644 index 0000000..b500ebb --- /dev/null +++ b/nixos/isos/common/users.nix @@ -0,0 +1,22 @@ +{ lib, ... }: + +{ + options.usersList = lib.mkOption { + type = lib.types.listOf lib.types.str; + }; + + config = { + usersList = [ "root" "nixos" "ruther" ]; + # usersList = lib.attrNames config.users.users? infrec? + + users.users = lib.mkMerge [ + { + ruther = { + isNormalUser = true; + extraGroups = [ "wheel" ]; + initialHashedPassword = ""; + }; + } + ]; + }; +} diff --git a/nixos/isos/common/vim.nix b/nixos/isos/common/vim.nix new file mode 100644 index 0000000..1f76cae --- /dev/null +++ b/nixos/isos/common/vim.nix @@ -0,0 +1,53 @@ +{ pkgs, ... }: + +{ + programs.neovim = { + defaultEditor = true; + enable = true; + vimAlias = true; + configure = { + customRC = '' + set iskeyword=!-~,^*,^45,^124,^34,192-255,^_,^.,^,,^/,^\ + syntax enable + + set relativenumber + set cc=80 + set list + + set smarttab + set expandtab + set shiftwidth=2 + set tabstop=2 + + highlight Comment cterm=italic gui=italic " Comments become italic + if &diff + colorscheme blue + endif + ''; + packages.myVimPackage = with pkgs.vimPlugins; { + start = [ + direnv-vim + + vim-nix + vim-markdown + + vim-lastplace + auto-pairs + vim-gitgutter + + wombat256-vim + srcery-vim + + lightline-vim + indent-blankline-nvim + + nvim-surround + vim-easymotion + vim-sneak + + vim-commentary + ]; + }; + }; + }; +} diff --git a/nixos/isos/default.nix b/nixos/isos/default.nix new file mode 100644 index 0000000..0a1dbcc --- /dev/null +++ b/nixos/isos/default.nix @@ -0,0 +1,34 @@ +{ lib, inputs }: + +let + depsInjectModule = { + options.deps-inject.inputs = lib.mkOption { type = with lib.types; attrsOf unspecified; }; + config.deps-inject.inputs = inputs; + }; + systemModule = system: { + nixpkgs.hostPlatform = system; + }; + + isos = { + gnome-install-iso = system: lib.nixosSystem { + modules = [ + ./gnome-installation.nix + depsInjectModule + (systemModule system) + ]; + }; + + # dwl-install-iso = system: lib.nixosSystem { + # modules = [ + # ./dwl-installation.nix + # depsInjectModule + # (systemModule system) + # ]; + # }; + }; + systems = [ "x86_64-linux" "aarch64-linux" ]; +in lib.genAttrs systems (system: + lib.mapAttrs + (name: iso: ((iso system).config.system.build.isoImage)) + isos +) diff --git a/nixos/isos/gnome-installation.nix b/nixos/isos/gnome-installation.nix new file mode 100644 index 0000000..1d0c82e --- /dev/null +++ b/nixos/isos/gnome-installation.nix @@ -0,0 +1,8 @@ +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = [ + (modulesPath + "/installer/cd-dvd/installation-cd-graphical-gnome.nix") + ./common + ]; +} -- 2.48.1