Skip to content

Commit

Permalink
Merge pull request #28 from lucernae/develop
Browse files Browse the repository at this point in the history
Merge NixOS Flake Setup
lucernae authored Mar 30, 2024
2 parents 7636e16 + d7b48fa commit d45db1b
Showing 11 changed files with 465 additions and 248 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/nix-build-using-debian.yaml
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ jobs:
- uses: actions/checkout@v4.1.1
- uses: cachix/install-nix-action@v26
with:
nix_path: nixpkgs=channel:nixos-20.09
nix_path: nixos=channel:nixos-23.05
extra_nix_config: |
extra-platforms = aarch64-linux
- name: Check nix.conf
@@ -78,7 +78,7 @@ jobs:
EOF
- name: Build SD Image
run: |
nix-build '<nixpkgs/nixos>' \
nix-build '<nixos/nixos>' \
-A config.system.build.sdImage \
-I nixos-config=./configuration.custom.sdImage.nix \
--argstr system aarch64-linux \
34 changes: 21 additions & 13 deletions .github/workflows/nix-build-using-docker.yaml
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ jobs:
- uses: actions/checkout@v4.1.1
- uses: cachix/install-nix-action@v26
with:
nix_path: nixpkgs=channel:nixos-20.09
nix_path: nixos=channel:nixos-23.05
extra_nix_config: |
extra-platforms = aarch64-linux
- name: Check nix.conf
@@ -27,13 +27,17 @@ jobs:
- name: Test binfmt availability
run: |
cat /proc/sys/fs/binfmt_misc/qemu-aarch64
# non flake way to build
# - name: Build SD Image
# run: |
# nix-build '<nixos/nixos>' \
# -A config.system.build.sdImage \
# -I nixos-config=./configuration.default.sdImage.nix \
# --argstr system aarch64-linux \
# --option sandbox false
- name: Build SD Image
run: |
nix-build '<nixpkgs/nixos>' \
-A config.system.build.sdImage \
-I nixos-config=./configuration.default.sdImage.nix \
--argstr system aarch64-linux \
--option sandbox false
nix build .#nixosConfigurations.raspberry-pi_3_default.config.system.build.sdImage
- uses: actions/upload-artifact@v4
with:
name: sd-image.img
@@ -49,7 +53,7 @@ jobs:
- uses: actions/checkout@v4.1.1
- uses: cachix/install-nix-action@v26
with:
nix_path: nixpkgs=channel:nixos-20.09
nix_path: nixos=channel:nixos-23.05
extra_nix_config: |
extra-platforms = aarch64-linux
- name: Check nix.conf
@@ -62,16 +66,20 @@ jobs:
cat /proc/sys/fs/binfmt_misc/qemu-aarch64
- name: Extract configuration from secrets
run: |
cat << EOF >> configuration.custom.sdImage.nix
cat << EOF >> configuration.nix
${{ secrets.CONFIGURATION_NIX }}
EOF
# non nix flake way to build
# - name: Build SD Image
# run: |
# nix-build '<nixos/nixos>' \
# -A config.system.build.sdImage \
# -I nixos-config=./configuration.custom.sdImage.nix \
# --argstr system aarch64-linux \
# --option sandbox false
- name: Build SD Image
run: |
nix-build '<nixpkgs/nixos>' \
-A config.system.build.sdImage \
-I nixos-config=./configuration.custom.sdImage.nix \
--argstr system aarch64-linux \
--option sandbox false
nix build .#nixosConfigurations.raspberry-pi_3_default.config.system.build.sdImage
- uses: actions/upload-artifact@v4
with:
name: sd-image.img
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -6,4 +6,9 @@ etc-pihole
.env
docker-compose.override.yml
result
sd-image.*
output
.direnv
.DS_Store
sd-image.*

.idea
31 changes: 26 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ Model:

# Using prebuilt image available on Hydra

The latest image is on Hydra:
The latest image is on Hydra (example. You might need to change NixOS version in the following URL):

[sd-image](https://hydra.nixos.org/job/nixos/release-20.09/nixos.sd_image.aarch64-linux/latest/download-by-type/file/sd-image)

@@ -47,7 +47,9 @@ I already setup a workflow manual dispatch Github Action in this repo, so to bui
1. Fork the repo so you can build your own custom image
2. Create your build/deployment environment.

From your repo settings page, click the Environments menu. Click New environment. Give it a name other than `default`. Define environment secrets called `CONFIGURATION_NIX`. The content should be your sd Image Nix recipe (not your future NixOS configuration.nix). See the sample template file in: [configuration.default.sdImage.nix](configuration.default.sdImage.nix) or [configuration.sdImage.nix](configuration.sdImage.nix)
From your repo settings page, click the Environments menu. Click New environment. Give it a name other than `default`. Define environment secrets called `CONFIGURATION_NIX`.
The content should be your custom `configuration.nix` file.
This will be imported by the `configuration.sdImage.nix`.

3. Run your workflow

@@ -99,7 +101,7 @@ The nix file must import the SD Image packages
{
imports = [
<nixpkgs/nixos/modules/installer/cd-dvd/sd-image-aarch64.nix>
<nixos/nixos/modules/installer/cd-dvd/sd-image-aarch64.nix>
];
# Do not compress the image as we want to use it straight away
@@ -114,7 +116,7 @@ See example in: [configuration.sdImage.nix](configuration.sdImage.nix)
Then build the image:

```
nix-build '<nixpkgs/nixos>' -A config.system.build.sdImage -I nixos-config=./configuration.sdImage.nix \
nix-build '<nixos/nixos>' -A config.system.build.sdImage -I nixos-config=./configuration.sdImage.nix \
--argstr system aarch64-linux \
--option sandbox false
```
@@ -147,10 +149,29 @@ The build command:

```
# notice that we don't need to specify --argstr system aarch64-linux
nix-build '<nixpkgs/nixos>' -A config.system.build.sdImage -I nixos-config=./configuration.sdImage.nix \
nix-build '<nixos/nixos>' -A config.system.build.sdImage -I nixos-config=./configuration.sdImage.nix \
--option sandbox false
```

# Building using Nix Flake

You must be on a NixOS machine or Nix on Linux. The architecture won't matter.

Following the previous guide on Building in x86_64 or ARM machine with Linux, the command is replaced
with Nix Flake command.

```shell
nix build .#nixosConfigurations.raspberry-pi_3.config.system.build.sdImage
```

Note, that since you can execute nix build on a remote flake, if your `configuration.nix` is already
stored in your repo, then you can build locally against remote flake (no need to git clone).

```shell
# example using this repo as the remote flake address
nix build github:lucernae/nixos-pi#nixosConfigurations.raspberry-pi_3.config.system.build.sdImage
```

# Building using Docker

Theoritically we can also build cross-platform using Docker container.
111 changes: 111 additions & 0 deletions configuration.default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
{ config, pkgs, lib, ... }:
{
# NixOS wants to enable GRUB by default
boot.loader.grub.enable = false;
# Enables the generation of /boot/extlinux/extlinux.conf
boot.loader.generic-extlinux-compatible.enable = true;

# !!! Set to specific linux kernel version
boot.kernelPackages = pkgs.linuxPackages;

# Disable ZFS on kernel 6
boot.supportedFilesystems = lib.mkForce [
"vfat"
"xfs"
"cifs"
"ntfs"
];

# !!! Needed for the virtual console to work on the RPi 3, as the default of 16M doesn't seem to be enough.
# If X.org behaves weirdly (I only saw the cursor) then try increasing this to 256M.
# On a Raspberry Pi 4 with 4 GB, you should either disable this parameter or increase to at least 64M if you want the USB ports to work.
boot.kernelParams = [ "cma=256M" ];

# File systems configuration for using the installer's partition layout
fileSystems = {
# Prior to 19.09, the boot partition was hosted on the smaller first partition
# Starting with 19.09, the /boot folder is on the main bigger partition.
# The following is to be used only with older images.
/*
"/boot" = {
device = "/dev/disk/by-label/NIXOS_BOOT";
fsType = "vfat";
};
*/
"/" = {
device = "/dev/disk/by-label/NIXOS_SD";
fsType = "ext4";
};
};

# !!! Adding a swap file is optional, but strongly recommended!
swapDevices = [{ device = "/swapfile"; size = 1024; }];

# Settings above are the bare minimum
# All settings below are customized depending on your needs

# systemPackages
environment.systemPackages = with pkgs; [
vim
curl
wget
nano
bind
kubectl
kubernetes-helm
iptables
openvpn
python3
nodejs
docker-compose
];

services.openssh = {
enable = true;
settings.PermitRootLogin = "yes";
};

programs.zsh = {
enable = true;
ohMyZsh = {
enable = true;
theme = "bira";
};
};


virtualisation.docker.enable = true;

networking.firewall.enable = false;

# WiFi
hardware = {
enableRedistributableFirmware = true;
firmware = [ pkgs.wireless-regdb ];
};

# put your own configuration here, for example ssh keys:
users.defaultUserShell = pkgs.zsh;
users.mutableUsers = true;
users.groups = {
nixos = {
gid = 1000;
name = "nixos";
};
};
users.users = {
nixos = {
uid = 1000;
home = "/home/nixos";
name = "nixos";
group = "nixos";
shell = pkgs.zsh;
extraGroups = [ "wheel" "docker" ];
};
};
users.users.root.openssh.authorizedKeys.keys = [
# Your ssh key
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDqlXJv/noNPmZMIfjJguRX3O+Z39xeoKhjoIBEyfeqgKGh9JOv7IDBWlNnd3rHVnVPzB9emiiEoAJpkJUnWNBidL6vPYn13r6Zrt/2WLT6TiUFU026ANdqMjIMEZrmlTsfzFT+OzpBqtByYOGGe19qD3x/29nbszPODVF2giwbZNIMo2x7Ww96U4agb2aSAwo/oQa4jQsnOpYRMyJQqCUhvX8LzvE9vFquLlrSyd8khUsEVV/CytmdKwUUSqmlo/Mn7ge/S12rqMwmLvWFMd08Rg9NHvRCeOjgKB4EI6bVwF8D6tNFnbsGVzTHl7Cosnn75U11CXfQ6+8MPq3cekYr lucernae@lombardia-N43SM"
];
system.stateVersion = "23.05";
}
77 changes: 6 additions & 71 deletions configuration.default.sdImage.nix
Original file line number Diff line number Diff line change
@@ -2,81 +2,16 @@
{

imports = [
<nixpkgs/nixos/modules/installer/cd-dvd/sd-image-aarch64.nix>
<nixos/nixos/modules/installer/sd-card/sd-image-aarch64-installer.nix>

# For nixpkgs cache
<nixpkgs/nixos/modules/installer/cd-dvd/channel.nix>
<nixos/nixos/modules/installer/cd-dvd/channel.nix>

# main configuration
./configuration.default.nix
];

sdImage.compressImage = true;


# NixOS wants to enable GRUB by default
boot.loader.grub.enable = false;
# Enables the generation of /boot/extlinux/extlinux.conf
boot.loader.generic-extlinux-compatible.enable = true;

# !!! Set to specific linux kernel version
boot.kernelPackages = pkgs.linuxPackages_5_4;

# !!! Needed for the virtual console to work on the RPi 3, as the default of 16M doesn't seem to be enough.
# If X.org behaves weirdly (I only saw the cursor) then try increasing this to 256M.
# On a Raspberry Pi 4 with 4 GB, you should either disable this parameter or increase to at least 64M if you want the USB ports to work.
boot.kernelParams = ["cma=256M"];

# Settings above are the bare minimum
# All settings below are customized depending on your needs

# systemPackages
environment.systemPackages = with pkgs; [
vim curl wget nano bind kubectl helm iptables openvpn
python3 nodejs-12_x docker-compose ];

services.openssh = {
enable = true;
permitRootLogin = "yes";
};

programs.zsh = {
enable = true;
ohMyZsh = {
enable = true;
theme = "bira";
};
};


virtualisation.docker.enable = true;

networking.firewall.enable = false;

# WiFi
hardware = {
enableRedistributableFirmware = true;
firmware = [ pkgs.wireless-regdb ];
};

# put your own configuration here, for example ssh keys:
users.defaultUserShell = pkgs.zsh;
users.mutableUsers = true;
users.groups = {
nixos = {
gid = 1000;
name = "nixos";
};
};
users.users = {
nixos = {
uid = 1000;
home = "/home/nixos";
name = "nixos";
group = "nixos";
shell = pkgs.zsh;
extraGroups = [ "wheel" "docker" ];
};
};
users.extraUsers.root.openssh.authorizedKeys.keys = [
# Your ssh key
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDqlXJv/noNPmZMIfjJguRX3O+Z39xeoKhjoIBEyfeqgKGh9JOv7IDBWlNnd3rHVnVPzB9emiiEoAJpkJUnWNBidL6vPYn13r6Zrt/2WLT6TiUFU026ANdqMjIMEZrmlTsfzFT+OzpBqtByYOGGe19qD3x/29nbszPODVF2giwbZNIMo2x7Ww96U4agb2aSAwo/oQa4jQsnOpYRMyJQqCUhvX8LzvE9vFquLlrSyd8khUsEVV/CytmdKwUUSqmlo/Mn7ge/S12rqMwmLvWFMd08Rg9NHvRCeOjgKB4EI6bVwF8D6tNFnbsGVzTHl7Cosnn75U11CXfQ6+8MPq3cekYr lucernae@lombardia-N43SM"
];
system.copySystemConfiguration = true;
}
95 changes: 61 additions & 34 deletions configuration.nix
Original file line number Diff line number Diff line change
@@ -4,25 +4,33 @@
boot.loader.grub.enable = false;
# Enables the generation of /boot/extlinux/extlinux.conf
boot.loader.generic-extlinux-compatible.enable = true;

# !!! Set to specific linux kernel version
boot.kernelPackages = pkgs.linuxPackages_5_4;
boot.kernelPackages = pkgs.linuxPackages;

# Disable ZFS on kernel 6
boot.supportedFilesystems = lib.mkForce [
"vfat"
"xfs"
"cifs"
"ntfs"
];

# !!! Needed for the virtual console to work on the RPi 3, as the default of 16M doesn't seem to be enough.
# If X.org behaves weirdly (I only saw the cursor) then try increasing this to 256M.
# On a Raspberry Pi 4 with 4 GB, you should either disable this parameter or increase to at least 64M if you want the USB ports to work.
boot.kernelParams = ["cma=256M"];
boot.kernelParams = [ "cma=256M" ];

# File systems configuration for using the installer's partition layout
fileSystems = {
# Prior to 19.09, the boot partition was hosted on the smaller first partition
# Starting with 19.09, the /boot folder is on the main bigger partition.
# The following is to be used only with older images.
/*
"/boot" = {
"/boot" = {
device = "/dev/disk/by-label/NIXOS_BOOT";
fsType = "vfat";
};
};
*/
"/" = {
device = "/dev/disk/by-label/NIXOS_SD";
@@ -31,29 +39,40 @@
};

# !!! Adding a swap file is optional, but strongly recommended!
swapDevices = [ { device = "/swapfile"; size = 1024; } ];
swapDevices = [{ device = "/swapfile"; size = 1024; }];

# systemPackages
environment.systemPackages = with pkgs; [
vim curl wget nano bind kubectl helm iptables openvpn
python3 nodejs-12_x docker-compose ];
environment.systemPackages = with pkgs; [
vim
curl
wget
nano
bind
kubectl
kubernetes-helm
iptables
openvpn
python3
nodejs
docker-compose
];

services.openssh = {
enable = true;
permitRootLogin = "yes";
enable = true;
settings.PermitRootLogin = "yes";
};

# Some sample service.
# Use dnsmasq as internal LAN DNS resolver.
services.dnsmasq = {
enable = false;
servers = [ "8.8.8.8" "8.8.4.4" "1.1.1.1" ];
extraConfig = ''
address=/fenrir.test/192.168.100.6
address=/recalune.test/192.168.100.7
address=/eth.nixpi.test/192.168.100.3
address=/wlan.nixpi.test/192.168.100.4
'';
enable = false;
settings.servers = [ "8.8.8.8" "8.8.4.4" "1.1.1.1" ];
settings.extraConfig = ''
address=/fenrir.test/192.168.100.6
address=/recalune.test/192.168.100.7
address=/eth.nixpi.test/192.168.100.3
address=/wlan.nixpi.test/192.168.100.4
'';
};

# services.openvpn = {
@@ -66,18 +85,18 @@
# };

programs.zsh = {
enable = true;
ohMyZsh = {
enable = true;
ohMyZsh = {
enable = true;
theme = "bira";
};
theme = "bira";
};
};


virtualisation.docker.enable = true;

networking.firewall.enable = false;


# WiFi
hardware = {
@@ -91,7 +110,7 @@
useDHCP = false;
ipv4.addresses = [{
# I used static IP over WLAN because I want to use it as local DNS resolver
address = "192.168.100.4";
address = "192.168.1.4";
prefixLength = 24;
}];
};
@@ -108,14 +127,21 @@
wireless.enable = true;
wireless.interfaces = [ "wlan0" ];
# If you want to connect also via WIFI to your router
wireless.networks."WIFI-SSID".psk = "wifipass";
# wireless.networks."SATRIA".psk = "wifipassword";
# You can set default nameservers
nameservers = [ "192.168.100.3" "192.168.100.4" "192.168.100.1" ];
# nameservers = [ "192.168.100.3" "192.168.100.4" "192.168.100.1" ];
# You can set default gateway
defaultGateway = {
address = "192.168.100.1";
interface = "wlan0";
};
# defaultGateway = {
# address = "192.168.1.1";
# interface = "eth0";
# };
};

# forwarding
boot.kernel.sysctl = {
"net.ipv4.conf.all.forwarding" = true;
"net.ipv6.conf.all.forwarding" = true;
"net.ipv4.tcp_ecn" = true;
};

# put your own configuration here, for example ssh keys:
@@ -137,8 +163,9 @@
extraGroups = [ "wheel" "docker" ];
};
};
users.extraUsers.root.openssh.authorizedKeys.keys = [
users.users.root.openssh.authorizedKeys.keys = [
# This is my public key
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDqlXJv/noNPmZMIfjJguRX3O+Z39xeoKhjoIBEyfeqgKGh9JOv7IDBWlNnd3rHVnVPzB9emiiEoAJpkJUnWNBidL6vPYn13r6Zrt/2WLT6TiUFU026ANdqMjIMEZrmlTsfzFT+OzpBqtByYOGGe19qD3x/29nbszPODVF2giwbZNIMo2x7Ww96U4agb2aSAwo/oQa4jQsnOpYRMyJQqCUhvX8LzvE9vFquLlrSyd8khUsEVV/CytmdKwUUSqmlo/Mn7ge/S12rqMwmLvWFMd08Rg9NHvRCeOjgKB4EI6bVwF8D6tNFnbsGVzTHl7Cosnn75U11CXfQ6+8MPq3cekYr lucernae@lombardia-N43SM"
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDqlXJv/noNPmZMIfjJguRX3O+Z39xeoKhjoIBEyfeqgKGh9JOv7IDBWlNnd3rHVnVPzB9emiiEoAJpkJUnWNBidL6vPYn13r6Zrt/2WLT6TiUFU026ANdqMjIMEZrmlTsfzFT+OzpBqtByYOGGe19qD3x/29nbszPODVF2giwbZNIMo2x7Ww96U4agb2aSAwo/oQa4jQsnOpYRMyJQqCUhvX8LzvE9vFquLlrSyd8khUsEVV/CytmdKwUUSqmlo/Mn7ge/S12rqMwmLvWFMd08Rg9NHvRCeOjgKB4EI6bVwF8D6tNFnbsGVzTHl7Cosnn75U11CXfQ6+8MPq3cekYr lucernae@lombardia-N43SM"
];
system.stateVersion = "23.05";
}
110 changes: 6 additions & 104 deletions configuration.sdImage.nix
Original file line number Diff line number Diff line change
@@ -2,114 +2,16 @@
{

imports = [
<nixpkgs/nixos/modules/installer/cd-dvd/sd-image-aarch64.nix>
<nixos/nixos/modules/installer/sd-card/sd-image-aarch64-installer.nix>

# For nixpkgs cache
<nixpkgs/nixos/modules/installer/cd-dvd/channel.nix>
<nixos/nixos/modules/installer/cd-dvd/channel.nix>

# main configuration
./configuration.nix
];

sdImage.compressImage = false;


# NixOS wants to enable GRUB by default
boot.loader.grub.enable = false;
# Enables the generation of /boot/extlinux/extlinux.conf
boot.loader.generic-extlinux-compatible.enable = true;

# !!! Set to specific linux kernel version
boot.kernelPackages = pkgs.linuxPackages_5_4;

# !!! Needed for the virtual console to work on the RPi 3, as the default of 16M doesn't seem to be enough.
# If X.org behaves weirdly (I only saw the cursor) then try increasing this to 256M.
# On a Raspberry Pi 4 with 4 GB, you should either disable this parameter or increase to at least 64M if you want the USB ports to work.
boot.kernelParams = ["cma=256M"];

# Settings above are the bare minimum
# All settings below are customized depending on your needs

# systemPackages
environment.systemPackages = with pkgs; [
vim curl wget nano bind kubectl helm iptables openvpn
python3 nodejs-12_x docker-compose ];

services.openssh = {
enable = true;
permitRootLogin = "yes";
};

programs.zsh = {
enable = true;
ohMyZsh = {
enable = true;
theme = "bira";
};
};


virtualisation.docker.enable = true;

networking.firewall.enable = false;

# WiFi
hardware = {
enableRedistributableFirmware = true;
firmware = [ pkgs.wireless-regdb ];
};

# Networking
networking = {
# useDHCP = true;
interfaces.wlan0 = {
useDHCP = false;
ipv4.addresses = [{
# I used static IP over WLAN because I want to use it as local DNS resolver
address = "192.168.100.4";
prefixLength = 24;
}];
};
interfaces.eth0 = {
useDHCP = true;
# I used DHCP because sometimes I disconnect the LAN cable
#ipv4.addresses = [{
# address = "192.168.100.3";
# prefixLength = 24;
#}];
};

# Enabling WIFI
wireless.enable = true;
wireless.interfaces = [ "wlan0" ];
# If you want to connect also via WIFI to your router
wireless.networks."WIFI-SSID".psk = "wifipass";
# You can set default nameservers
nameservers = [ "192.168.100.3" "192.168.100.4" "192.168.100.1" ];
# You can set default gateway
defaultGateway = {
address = "192.168.100.1";
interface = "wlan0";
};
};

# put your own configuration here, for example ssh keys:
users.defaultUserShell = pkgs.zsh;
users.mutableUsers = true;
users.groups = {
nixos = {
gid = 1000;
name = "nixos";
};
};
users.users = {
nixos = {
uid = 1000;
home = "/home/nixos";
name = "nixos";
group = "nixos";
shell = pkgs.zsh;
extraGroups = [ "wheel" "docker" ];
};
};
users.extraUsers.root.openssh.authorizedKeys.keys = [
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDqlXJv/noNPmZMIfjJguRX3O+Z39xeoKhjoIBEyfeqgKGh9JOv7IDBWlNnd3rHVnVPzB9emiiEoAJpkJUnWNBidL6vPYn13r6Zrt/2WLT6TiUFU026ANdqMjIMEZrmlTsfzFT+OzpBqtByYOGGe19qD3x/29nbszPODVF2giwbZNIMo2x7Ww96U4agb2aSAwo/oQa4jQsnOpYRMyJQqCUhvX8LzvE9vFquLlrSyd8khUsEVV/CytmdKwUUSqmlo/Mn7ge/S12rqMwmLvWFMd08Rg9NHvRCeOjgKB4EI6bVwF8D6tNFnbsGVzTHl7Cosnn75U11CXfQ6+8MPq3cekYr lucernae@lombardia-N43SM"
];
system.copySystemConfiguration = true;
}
147 changes: 147 additions & 0 deletions flake.lock
69 changes: 69 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
devshell.url = "github:numtide/devshell";
};

outputs = { self, nixpkgs, flake-utils, devshell, ... }:
flake-utils.lib.eachDefaultSystem (system: {
apps.devshell = self.outputs.devShell.${system}.flakeApp;
formatter = nixpkgs.legacyPackages.${system}.nixpkgs-fmt;
packages = {
nixosConfigurations =
let
inherit (nixpkgs.lib) nixosSystem;
in
rec {
# to build: nix build github:lucernae/nix-config#nixosConfigurations.raspberry-pi_3.config.system.build.sdImage
raspberry-pi_3 = nixosSystem {
system = "aarch64-linux";
modules = [
"${nixpkgs}/nixos/modules/installer/sd-card/sd-image-aarch64-installer.nix"
# replace this with your target configuration
./configuration.nix

# extra config for sdImage generator
{
sdImage.compressImage = false;
}
];
};
raspberry-pi_3_default = nixosSystem {
system = "aarch64-linux";
modules = [
"${nixpkgs}/nixos/modules/installer/sd-card/sd-image-aarch64-installer.nix"
# replace this with your target configuration
./configuration.default.nix

# extra config for sdImage generator
{
sdImage.compressImage = false;
}
];
};
};
};
devShell =
let
pkgs = import nixpkgs {
inherit system;
overlays = [ devshell.overlays.default ];
};
in
pkgs.devshell.mkShell {
name = "nixos-pi";
commands = [
];
packages = with pkgs; [
git
qemu
qemu_kvm
];
};
});
}
28 changes: 10 additions & 18 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
let _pkgs = import <nixpkgs> { };
in { pkgs ? import (_pkgs.fetchFromGitHub {
owner = "NixOS";
repo = "nixpkgs-channels";
#branch@date: nixpkgs-unstable@2021-01-25
rev = "502845c3e31ef3de0e424f3fcb09217df2ce6df6";
sha256 = "0fcqpsy6y7dgn0y0wgpa56gsg0b0p8avlpjrd79fp4mp9bl18nda";
}) { } }:

with pkgs;

mkShell {
buildInputs = [
git
qemu
qemu_kvm
];
}
(import
(
let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}
)
{ src = ./.; }
).shellNix

0 comments on commit d45db1b

Please sign in to comment.