Skip to content

Commit

Permalink
nixos/sourcehut: no pin on nixos version
Browse files Browse the repository at this point in the history
  • Loading branch information
tomberek committed Jun 11, 2021
1 parent e2cd9eb commit 0f8f609
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{ pkgs, ... }:

{
# passwordless ssh server
services.openssh = {
enable = true;
permitRootLogin = "yes";
extraConfig = "PermitEmptyPasswords yes";
};

users = {
mutableUsers = false;
# build user
extraUsers."build" = {
isNormalUser = true;
uid = 1000;
extraGroups = [ "wheel" ];
password = "";
};
users.root.password = "";
};
security.sudo.wheelNeedsPassword = false;
nix.trustedUsers = [ "root" "build" ];

# builds.sr.ht-image-specific network settings
networking = {
hostName = "build";
dhcpcd.enable = false;
defaultGateway.address = "10.0.2.2";
usePredictableInterfaceNames = false; # so that we just get eth0 and not some weird id
interfaces."eth0".ipv4.addresses = [{
address = "10.0.2.15";
prefixLength = 25;
}];
enableIPv6 = false;
nameservers = [
# OpenNIC anycast
"185.121.177.177"
"169.239.202.202"
# Google as a fallback :(
"8.8.8.8"
];
firewall.allowedTCPPorts = [ 22 ]; # allow ssh
};

environment.systemPackages = with pkgs; [
gitMinimal
mercurial
curl
gnupg
];
}

33 changes: 29 additions & 4 deletions nixos/modules/services/misc/sourcehut/builds.nix
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,37 @@ in
rev = "ff96a0fa5635770390b184ae74debea75c3fd534";
ref = "nixos-unstable";
};
image_from_nixpkgs = pkgs_unstable: (import ("${pkgs.sourcehut.buildsrht}/lib/images/nixos/image.nix") {
pkgs = (import pkgs_unstable {});
});
image_from_nixpkgs = pkgs:
let
makeDiskImage = import ../../../lib/make-disk-image.nix;
evalConfig = import ../../../lib/eval-config.nix;
config = (evalConfig {
modules = [ (import ./qemu-system-configuration.nix) ];
inherit pkgs;
}).config;
in
makeDiskImage {
inherit pkgs config;
lib = pkgs.lib;
diskSize = 16000;
format = "qcow2-compressed";
contents = [{
source = pkgs.writeText "gitconfig" '''
[user]
name = builds.sr.ht
email = builds@sr.ht
''';
target = "/home/build/.gitconfig";
user = "build";
group = "users";
mode = "644";
}];
};
in
{
nixos.unstable.x86_64 = image_from_nixpkgs pkgs_unstable;
nixos.unstable.x86_64 = image_from_nixpkgs pkgs;
}
)'';
description = ''
Expand Down
29 changes: 29 additions & 0 deletions nixos/modules/services/misc/sourcehut/image.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{ pkgs ? import <nixpkgs> {} }:

let
#makeDiskImage = import (pkgs.path +"/nixos/lib/make-disk-image.nix");
makeDiskImage = import ../../../../lib/make-disk-image.nix;
evalConfig = import ../../../../lib/eval-config.nix;
config = (evalConfig {
modules = [ (import ./qemu-system-configuration.nix) ];
system = "x86_64-linux";
}).config;
in
makeDiskImage {
inherit pkgs config;
lib = pkgs.lib;
diskSize = 16000;
format = "qcow2-compressed";
contents = [{
source = pkgs.writeText "gitconfig" ''
[user]
name = builds.sr.ht
email = builds@sr.ht
'';
target = "/home/build/.gitconfig";
user = "build";
group = "users";
mode = "644";
}];
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{ pkgs, ... }:

{
imports = [ ./base-system-configuration.nix ];
fileSystems."/".device = "/dev/disk/by-label/nixos";
boot.initrd.availableKernelModules = [ "xhci_pci" "ehci_pci" "ahci" "usbhid" "usb_storage" "sd_mod" "virtio_balloon" "virtio_blk" "virtio_pci" "virtio_ring" ];
boot.loader = {
grub = {
version = 2;
device = "/dev/vda";
};
timeout = 0;
};
}

0 comments on commit 0f8f609

Please sign in to comment.