Skip to content

Commit

Permalink
Merge branch 'fenrir'
Browse files Browse the repository at this point in the history
  • Loading branch information
M-Gregoire committed Dec 23, 2019
2 parents 8e95ec1 + 9322fb6 commit 7e99ac7
Show file tree
Hide file tree
Showing 28 changed files with 247 additions and 39 deletions.
54 changes: 51 additions & 3 deletions INSTALLING.md
@@ -1,5 +1,52 @@
# Install

## Standard install (BIOS)

```
parted /dev/sda -- mklabel msdos
parted /dev/sda -- mkpart primary 1MiB -8GiB
parted /dev/sda -- mkpart primary linux-swap -8GiB 100%
mkfs.ext4 -L nixos /dev/sda1
mkswap -L swap /dev/sda2
mount /dev/disk/by-label/nixos /mnt
swapon /dev/sda2
nixos-generate-config --root /mnt
# Copy initial-config.nix to /etc/nixos/configuration.nix
# Uncomment BIOS section and comment the EFI section
# Also copy wpa_supplicant.conf in /etc if Wifi is needed
# /!\ Save hardware-configuration.nix to this repo!
nixos-install
reboot
```

## Standard install (UEFI)

```
parted /dev/sda -- mklabel gpt
parted /dev/sda -- mkpart primary 512MiB -8GiB
parted /dev/sda -- mkpart primary linux-swap -8GiB 100%
parted /dev/sda -- mkpart ESP fat32 1MiB 512MiB
parted /dev/sda -- set 3 boot on
mkfs.ext4 -L nixos /dev/sda1
mkswap -L swap /dev/sda2
mkfs.fat -F 32 -n boot /dev/sda3
mount /dev/disk/by-label/nixos /mnt
mkdir -p /mnt/boot
mount /dev/disk/by-label/boot /mnt/boot
swapon /dev/sda2
nixos-generate-config --root /mnt
# Copy initial-config.nix to /etc/nixos/configuration.nix
# Also copy wpa_supplicant.conf in /etc if Wifi is needed
# /!\ Save hardware-configuration.nix to this repo!
nixos-install
reboot
```

## LVM/LUKS install
This documentation describes how to install NixOS with LVM and LUKS.
This is heavily based on [https://qfpl.io/posts/installing-nixos/](https://qfpl.io/posts/installing-nixos/).

Expand Down Expand Up @@ -64,8 +111,8 @@ nixos-generate-config --root /mnt
# Copy initial-config.nix to /etc/nixos/configuration.nix
# Also copy wpa_supplicant.conf in /etc if Wifi is needed
# Edit initial-config.nix to uncomment LUKS section if needed
# If so, set correct Luks drive
# Edit initial-config.nix to uncomment LUKS section
# And set correct Luks drive
# /!\ Save hardware-configuration.nix to this repo!
# Install
Expand All @@ -77,6 +124,7 @@ reboot
# If no other device is available, go to the next step directly.
```

## Post-install for PCs
Everything should now be installed on the host. However, local deployement will not work as the github repo will not have been cloned, channels are not set and some local files might be missing. To do so, on the newly installed device:

```
Expand All @@ -94,7 +142,7 @@ sudo nix-channel --add https://nixos.org/channels/nixpkgs-unstable unstable; sud
sudo nixos-rebuild switch
```

# Mount from live
## Mount from live with LUKS
```
cryptsetup luksOpen /dev/sda2 nixos-enc
lvscan
Expand Down
7 changes: 4 additions & 3 deletions dotfiles/emacs.d/init.el
Expand Up @@ -39,9 +39,10 @@
(setq save-abbrevs 'silent)

;; Use use-package
(package-install 'use-package)
(eval-when-compile
(require 'use-package))
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(require 'use-package)

;; Install all packages if not installed
(require 'use-package-ensure
Expand Down
9 changes: 8 additions & 1 deletion initial-config.nix
Expand Up @@ -15,6 +15,13 @@
# }
#];

# BIOS
#boot.loader.grub = {
# enable = true;
# version = 2;
# device = "/dev/sda";
#};

# UEFI
boot.loader.systemd-boot.enable = true;
# General settings
Expand Down Expand Up @@ -60,7 +67,7 @@
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC3dchSro0m3PmK0ZjxwRZ7kthxIzVU6T+apdG09/7vH/TS9UfoAB3fSUs80dplXB6UxzRmqNdqh5vHd9SUMre/S8NPmFCwwM98bqUNCNx6ZMwstSY/15PCVUkQk8fBXI4L/eUvYGpkBX3jjvqp75XWR8yIvx7l6189ljmt4Wrt1p6gUxJKRO8PjZxFHriAykNOC+MtOkjseT0iK//ij7XYj6zYq1fQLw92lB4AWgw3dvRmhag79yHeKVT2zCBD4zw8q9gAGIp6vc+5L3X/5q2i8wm9hh/TeBY3IhFOiMzzYbPMWIjsx4tk6iUv2Gtpdp/B0Nx/FnlEtS1MZeWfjwA6vQFWS/G/OPM2SHbUmzgJ4lufm2yEj67P0vGSPvHg7uonxhf5OVf8J+p8bmVC5s4SEG5aKuBN/+9El71joN7491+mEWGAl0PqJbDU5UEC6wYigx2wAUVtF3mB5QtbKiZ5UYVly/u+ejACr+K2651+EEAqjPx4xrRm9tlLn2LslMCuRQ2QDzOcl5iM3ZkCbAHIFS8ZGc94w84SNL22jV6kPLcrs8S5isO79cDYuxqUM/Aa3VpYuminpUFNEPYy25UjNtWZUFp2kef1JP9dAD27pWCW1Nlgc0SqmEusBsvflzdQmhvCZuBCU/Xy16WPb2WL8lxcCZVuQvcPKz3dgGQD5w== m-gregoire"
];

system.stateVersion = "18.09";
system.stateVersion = "19.03";

# For SSH
# https://askubuntu.com/questions/54145/how-to-fix-strange-backspace-behaviour-with-urxvt-zsh
Expand Down
32 changes: 32 additions & 0 deletions modules/default.nix
Expand Up @@ -151,6 +151,38 @@
description = "Domain aliases";
};
};
fenrir = {
ip.default = mkOption {
type = types.str;
example = "1.1.1.1";
description = "Ip of the host";
};
ssh.port = mkOption {
type = types.port;
example = [ "22" ];
description = "Specifies on which port the SSH daemon listens.";
};
extraDomains = mkOption {
type = types.listOf types.str;
description = "Domain aliases";
};
};
fenrirDocker = {
ip.default = mkOption {
type = types.str;
example = "1.1.1.1";
description = "Ip of the host";
};
ssh.port = mkOption {
type = types.port;
example = [ "22" ];
description = "Specifies on which port the SSH daemon listens.";
};
extraDomains = mkOption {
type = types.listOf types.str;
description = "Domain aliases";
};
};
mimir = {
ip = {
default = mkOption {
Expand Down
10 changes: 10 additions & 0 deletions nixops/Fenrir.nix
@@ -0,0 +1,10 @@
{
FenrirDocker =
{ config, pkgs, ... }:
{
deployment = {
targetHost = "FenrirDocker";
targetPort = config.resources.hosts.fenrirDocker.ssh.port;
};
};
}
21 changes: 15 additions & 6 deletions nixops/generateDeployment.sh
@@ -1,11 +1,20 @@
#!/usr/bin/env bash

nixops create home.nix Bur.nix Mimir.nix Skuld.nix -d home
nixops destroy -d home 2> /dev/null
nixops destroy -d cloud 2> /dev/null
nixops destroy -d pcs 2> /dev/null
nixops destroy -d servers 2> /dev/null
nixops delete -d home 2> /dev/null
nixops delete -d cloud 2> /dev/null
nixops delete -d pcs 2> /dev/null
nixops delete -d servers 2> /dev/null

nixops create home.nix Bur.nix Mimir.nix Skuld.nix Fenrir.nix -d home
nixops create cloud.nix Eldir.nix -d cloud
nixops create pcs.nix Bur.nix Mimir.nix -d pcs
nixops create servers.nix Eldir.nix Skuld.nix -d servers
nixops create servers.nix Eldir.nix Skuld.nix Fenrir.nix -d servers

nixops deploy -d home
nixops deploy -d cloud
nixops deploy -d pcs
nixops deploy -d servers
#nixops deploy -d home
#nixops deploy -d cloud
#nixops deploy -d pcs
#nixops deploy -d servers
9 changes: 9 additions & 0 deletions nixops/home.nix
Expand Up @@ -27,4 +27,13 @@
../nixos/hosts/Skuld/configuration.nix
];
};

FenrirDocker =
{ config, pkgs, ... }:
{
imports =
[
../nixos/hosts/FenrirDocker/configuration.nix
];
};
}
9 changes: 9 additions & 0 deletions nixops/servers.nix
Expand Up @@ -18,4 +18,13 @@
../nixos/hosts/Skuld/configuration.nix
];
};

FenrirDocker =
{ config, pkgs, ... }:
{
imports =
[
../nixos/hosts/FenrirDocker/configuration.nix
];
};
}
3 changes: 2 additions & 1 deletion nixos/common.nix
Expand Up @@ -39,7 +39,8 @@
nixpkgs.overlays = import ../nixpkgs/overlays.nix;

networking.hostName = config.resources.hostname;
networking.nameservers = config.resources.networking.DNS;
#


networking.firewall.allowedTCPPorts = config.resources.networking.firewall.openTCPPorts;
networking.firewall.allowedUDPPorts = config.resources.networking.firewall.openUDPPorts;
Expand Down
13 changes: 13 additions & 0 deletions nixos/dev/boot/grub-bios.nix
@@ -0,0 +1,13 @@
{ config, ... }:

{
# BIOS
# General settings
boot.loader.timeout = 2;
# GRUB
boot.loader.grub = {
enable = true;
version = 2;
device = "/dev/sda";
};
}
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions nixos/hosts/Bur/configuration.nix
Expand Up @@ -3,15 +3,15 @@
{
imports =
[
./../../dev/luks.nix
../../../resources/hosts/Bur
../../../vendor/infrastructure-private/resources/hosts/Bur
../../common.nix
../../dev/bluetooth.nix
../../dev/boot/grub-uefi.nix
../../dev/suspend.nix
../../grub.nix
../../networks/home
../../profiles/PC
./../../dev/luks.nix
./hardware-configuration.nix
];

Expand Down
36 changes: 36 additions & 0 deletions nixos/hosts/FenrirDocker/configuration.nix
@@ -0,0 +1,36 @@
{ config, pkgs, ... }:

{
imports = [
../../../resources/hosts/FenrirDocker
../../../vendor/infrastructure-private/resources/hosts/FenrirDocker
../../common.nix
../../dev/bluetooth.nix
../../dev/boot/grub-bios.nix
../../dev/nfs.nix
../../dev/wireguard-server.nix
../../networks/home
../../profiles/Server
./hardware-configuration.nix
];

networking.firewall.allowedTCPPorts = [ config.resources.hosts.fenrirDocker.ssh.port ];
services.openssh.ports = [ config.resources.hosts.fenrirDocker.ssh.port ];

networking.hosts = {
# This part is used to define custom DNS records by my PiHole
"${config.resources.hosts.bur.ip.default}" = [ "Bur" "${builtins.concatStringsSep " " config.resources.hosts.bur.extraDomains}" ];
"${config.resources.hosts.eldir.ip.default}" = [ "Eldir" "${builtins.concatStringsSep " " config.resources.hosts.eldir.extraDomains}" ];
"${config.resources.hosts.idunn.ip.default}" = [ "Idunn" "${builtins.concatStringsSep " " config.resources.hosts.idunn.extraDomains}" ];
"${config.resources.hosts.mimir.ip.default}" = [ "Mimir" "${builtins.concatStringsSep " " config.resources.hosts.mimir.extraDomains}" ];
"${config.resources.hosts.skuld.ip.default}" = [ "Skuld" "${builtins.concatStringsSep " " config.resources.hosts.skuld.extraDomains}" ];
"${config.resources.hosts.fenrir.ip.default}" = [ "Fenrir" "${builtins.concatStringsSep " " config.resources.hosts.fenrir.extraDomains}" ];
# Basic hostname already defined in the home profile
"${config.resources.hosts.beyla.ip.default}" = [ "${builtins.concatStringsSep " " config.resources.hosts.beyla.extraDomains}" ];
"${config.resources.hosts.octopi.ip.default}" = [ "${builtins.concatStringsSep " " config.resources.hosts.octopi.extraDomains}" ];
# Basic hostname binded to localhost
"${config.resources.hosts.fenrirDocker.ip.default}" = [ "${builtins.concatStringsSep " " config.resources.hosts.fenrirDocker.extraDomains}" ];
} // config.resources.hosts.extra;

system.stateVersion = "19.09";
}
24 changes: 24 additions & 0 deletions nixos/hosts/FenrirDocker/hardware-configuration.nix
@@ -0,0 +1,24 @@
# Do not modify this file! It was generated by ‘nixos-generate-config’
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, ... }:

{
imports =
[ <nixpkgs/nixos/modules/profiles/qemu-guest.nix>
];

boot.initrd.availableKernelModules = [ "ata_piix" "uhci_hcd" "virtio_pci" "sd_mod" "sr_mod" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ ];
boot.extraModulePackages = [ ];

fileSystems."/" =
{ device = "/dev/disk/by-uuid/95112719-5914-4701-b56f-55effa844554";
fsType = "ext4";
};

swapDevices = [ ];

nix.maxJobs = lib.mkDefault 1;
}
File renamed without changes.
4 changes: 2 additions & 2 deletions nixos/hosts/Mimir/configuration.nix
Expand Up @@ -3,16 +3,16 @@
{
imports =
[
./../../dev/luks.nix
../../../resources/hosts/Mimir
../../../vendor/infrastructure-private/resources/hosts/Mimir
../../common.nix
../../dev/bluetooth.nix
../../dev/boot/grub-uefi.nix
../../dev/steam.nix
../../dev/virtualbox.nix
../../grub.nix
../../networks/home
../../profiles/PC
./../../dev/luks.nix
./hardware-configuration.nix
];

Expand Down
15 changes: 1 addition & 14 deletions nixos/hosts/Skuld/configuration.nix
Expand Up @@ -6,31 +6,18 @@
../../../vendor/infrastructure-private/resources/hosts/Skuld
../../common.nix
../../dev/bluetooth.nix
../../dev/boot/systemd-boot.nix
../../dev/nfs.nix
../../dev/wireguard-server.nix
../../networks/home
../../profiles/Server
../../systemd-boot.nix
./hardware-configuration.nix
./mail-server.nix
];

networking.firewall.allowedTCPPorts = [ config.resources.hosts.skuld.ssh.port ];
services.openssh.ports = [ config.resources.hosts.skuld.ssh.port ];

networking.hosts = {
# This part is used to define custom DNS records by my Octopi
"${config.resources.hosts.bur.ip.default}" = [ "Bur" "${builtins.concatStringsSep " " config.resources.hosts.bur.extraDomains}" ];
"${config.resources.hosts.eldir.ip.default}" = [ "Eldir" "${builtins.concatStringsSep " " config.resources.hosts.eldir.extraDomains}" ];
"${config.resources.hosts.idunn.ip.default}" = [ "Idunn" "${builtins.concatStringsSep " " config.resources.hosts.idunn.extraDomains}" ];
"${config.resources.hosts.mimir.ip.default}" = [ "Mimir" "${builtins.concatStringsSep " " config.resources.hosts.mimir.extraDomains}" ];
# Basic hostname already defined in the home profile
"${config.resources.hosts.beyla.ip.default}" = [ "${builtins.concatStringsSep " " config.resources.hosts.beyla.extraDomains}" ];
"${config.resources.hosts.octopi.ip.default}" = [ "${builtins.concatStringsSep " " config.resources.hosts.octopi.extraDomains}" ];
# Basic hostname binded to localhost
"${config.resources.hosts.skuld.ip.default}" = [ "${builtins.concatStringsSep " " config.resources.hosts.skuld.extraDomains}" ];
} // config.resources.hosts.extra;

boot.loader.efi.canTouchEfiVariables = true;
boot.loader.grub.efiSupport = false;

Expand Down
2 changes: 2 additions & 0 deletions nixos/networks/cloud/default.nix
Expand Up @@ -4,4 +4,6 @@
imports = [
../../../vendor/infrastructure-private/resources/networks/cloud/default.nix
];

networking.nameservers = config.resources.networking.DNS;
}

0 comments on commit 7e99ac7

Please sign in to comment.