Initial commit

This commit is contained in:
Jakub Skokan 2018-08-02 12:52:11 +02:00
commit 830f33f7c4
11 changed files with 221 additions and 0 deletions

26
lib/vpsadminos/local.nix Normal file
View File

@ -0,0 +1,26 @@
let
nixpkgsPath = "/home/aither/workspace/vpsadmin/nixpkgs";
vpsadminosPath = "/home/aither/workspace/vpsadmin/vpsadminos";
in
{
vpsadminos = {configuration, modules ? []}:
let
# this is fed into scopedImport so vpsadminos sees correct <nixpkgs> everywhere
overrides = {
__nixPath = [
{ prefix = "nixpkgs"; path = nixpkgsPath; }
{ prefix = "vpsadminos"; path = vpsadminosPath; }
] ++ builtins.nixPath;
import = fn: scopedImport overrides fn;
scopedImport = attrs: fn: scopedImport (overrides // attrs) fn;
builtins = builtins // overrides;
};
in
builtins.scopedImport overrides (vpsadminosPath + "/os/") {
nixpkgs = nixpkgsPath;
system = "x86_64-linux";
extraModules = modules;
inherit configuration;
};
}

40
lib/vpsadminos/pinned.nix Normal file
View File

@ -0,0 +1,40 @@
let
pkgs = import <nixpkgs> {};
in
{
vpsadminos_spec = builtins.fromJSON (builtins.readFile ./pinned/vpsadminos.json);
vpsadminosGit = builtins.trace vpsadminos_spec pkgs.fetchgit {
inherit (vpsadminos_spec) url rev sha256;
leaveDotGit = true;
};
nixpkgsVpsFree_spec = builtins.fromJSON (builtins.readFile ./pinned/nixpkgs-vpsfreecz.json);
nixpkgsVpsFreeGit = pkgs.fetchgit {
inherit (nixpkgsVpsFree_spec) url rev sha256;
leaveDotGit = true;
};
nixpkgsVpsFree = import nixpkgsVpsFreeGit {};
vpsadminos = {configuration, modules ? []}:
let
# this is fed into scopedImport so vpsadminos sees correct <nixpkgs> everywhere
overrides = {
__nixPath = [
{ prefix = "nixpkgs"; path = nixpkgsVpsFree.path; }
{ prefix = "vpsadminos"; path = vpsadminosGit; }
] ++ builtins.nixPath;
import = fn: scopedImport overrides fn;
scopedImport = attrs: fn: scopedImport (overrides // attrs) fn;
builtins = builtins // overrides;
};
in
builtins.scopedImport overrides (vpsadminosGit + "/os/") {
nixpkgs = nixpkgsVpsFree.path;
system = "x86_64-linux";
extraModules = modules;
inherit configuration;
};
}

View File

@ -0,0 +1,44 @@
{ config, pkgs, ... }:
{
imports = [
<vpsadminos/os/configs/common.nix>
./hardware-configuration.nix
];
#deployment.targetHost = "192.168.2.106";
boot.loader.grub.enable = true;
boot.loader.grub.version = 2;
boot.loader.grub.device = "/dev/sda"; # or "nodev" for efi only
networking.hostName = "vosa"; # Define your hostname.
networking.dhcp = true;
networking.dhcpd = true;
networking.lxcbr = true;
networking.nat = true;
i18n = {
consoleFont = "Lat2-Terminus16";
consoleKeyMap = "us";
defaultLocale = "en_US.UTF-8";
};
time.timeZone = "Europe/Prague";
environment.systemPackages = with pkgs; [
git
htop
nano
vim
wget
];
services.openssh.enable = true;
users.extraUsers.root.openssh.authorizedKeys.keys = [
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCyWNChi95oRKXtSGdXtbthvXgWXk4y7uqpKVSIfqPq5GzI/S5WmAGe73Tc6o7aBzby09xpmLI/i41+jzQdSfxrGoCFRvpV+2W221jcdWyF/ojXiUciX2dQGS1gsKVcYNjLmqUrN/fNgY5XjuB10VU3nCenmRGGPep1Sx8CYi61lf5Qxb0AF71ylNJ8/rEXjkXad1vi7zTFteEWj3MmOoK1Fau4ykr6o4v2lSRWEvIxY9S+AFwNVqBtCC210ks1XYInaYuPnz0mdRmoOQIATLdBvIyHuWW5y8M9K+aplkLrUBI8abbrLcGze3lRusx4S3w2V4Pvgt9+DtpRM+kyC5gBhUxO8rY7+pBiIWP0WF87Xs5XfUe+nlhnbp23A/rAppvT6NnpvY10bvWTnKbnBlSyGWPUlYLVdqRwshLNSIKr2YByWorzNtnP63rTe5E8gHnpMs3+4f1Rdz0xgSx8kNZ0vAi7w2moFsjwQzc94Uzy52SkYkGgFYpkystXP05GKyB4N0nStoU25KmdX8dsSYGzF0WERy8KWx0tr1Hv/YONWek7IIHDZin5cTyhkbyktenlAyLJ5uj9Oty4MgKPsE3+GrMdczVTBf5ThhSuvyrZo2CqjTSBc6j7mEyEAAHqM6JNVyPRqhDYmtaK0iLTJCAyqnzQyLD9gxEBuTj/o+3rcw== aither@orion"
];
system.nixos.stateVersion = "18.03";
}

View File

@ -0,0 +1,18 @@
{ config, lib, pkgs, ... }:
{
boot.initrd.availableKernelModules = [ "ata_piix" "uhci_hcd" "ehci_pci" "ahci" "sd_mod" "sr_mod" ];
boot.kernelModules = [ ];
boot.extraModulePackages = [ ];
boot.kernelParams = [ "root=/dev/sda1" "nolive" ];
boot.initrd.kernelModules = [ "ext4" ];
fileSystems."/" =
{ device = "/dev/disk/by-uuid/41c4fbd1-7080-47b5-84c2-1f0b5694f0a5";
fsType = "ext4";
};
swapDevices = [ ];
nix.maxJobs = lib.mkDefault 6;
}

7
network-libvirt.nix Normal file
View File

@ -0,0 +1,7 @@
{
vosa =
{ config, lib, pkgs, ... }:
{
deployment.targetHost = "192.168.2.106";
};
}

21
network.nix Normal file
View File

@ -0,0 +1,21 @@
let
#pinned = import ./lib/vpsadminos/pinned.nix;
pinned = import ./lib/vpsadminos/local.nix;
in
{
network.description = "testish infrastructure";
vosa =
#{ config, pkgs, lib, ...}:
let
osCfg = (pinned.vpsadminos { configuration = ./machines/vosa/configuration.nix; }).config;
nixopsCfg = {
deployment.targetHost = "192.168.2.106";
environment.checkConfigurationOptions = true;
};
in
osCfg // nixopsCfg;
# vosa =
# (pinned.vpsadminos { configuration = ./machines/vosa/configuration.nix; }).config;
}

47
pinned/default.nix Normal file
View File

@ -0,0 +1,47 @@
{ lib, pkgs, ... }:
with builtins;
rec {
vpsadminos_spec = builtins.fromJSON (builtins.readFile ./pinned/vpsadminos.json);
vpsadminosGit = trace vpsadminos_spec pkgs.fetchgit {
inherit (vpsadminos_spec) url rev sha256;
leaveDotGit = true;
};
# if you need to build directly from git for testing
# - uses filterSource to get rid of .git and a custom filter to exclude possible disk images
/*
vpsadminosGit = builtins.filterSource (p: t:
lib.cleanSourceFilter p t
&& (!lib.hasSuffix "img" (baseNameOf p))
&& (baseNameOf p != "local.nix")
) ../../git/vpsadminos;
*/
nixpkgsVpsFree_spec = builtins.fromJSON (builtins.readFile ./pinned/nixpkgs-vpsfreecz.json);
nixpkgsVpsFreeGit = pkgs.fetchgit {
inherit (nixpkgsVpsFree_spec) url rev sha256;
leaveDotGit = true;
};
nixpkgsVpsFree = import nixpkgsVpsFreeGit {};
vpsadminos = {modules ? []}:
let
# this is fed into scopedImport so vpsadminos sees correct <nixpkgs> everywhere
overrides = {
__nixPath = [ { prefix = "nixpkgs"; path = nixpkgsVpsFree.path; } ] ++ builtins.nixPath;
import = fn: scopedImport overrides fn;
scopedImport = attrs: fn: scopedImport (overrides // attrs) fn;
builtins = builtins // overrides;
};
in
builtins.scopedImport overrides (vpsadminosGit + "/os/") {
nixpkgs = nixpkgsVpsFree.path;
system = "x86_64-linux";
extraModules = modules;
vpsadmin = vpsadminGit;
};
vpsadminosBuild = {modules ? []}: (vpsadminos { inherit modules; }).config.system.build;
}

View File

@ -0,0 +1,7 @@
{
"url": "https://github.com/vpsfreecz/nixpkgs",
"rev": "f33f79e01a14b9698637ce26c72ff92a6a2057ba",
"date": "2018-07-14T19:32:30+02:00",
"sha256": "0yv3zl6dmw8frgdblscyckxqxfgh44n0s5j9f3h7hbm704yn0g76",
"fetchSubmodules": true
}

2
pinned/pin_nixpkgs_vpsfree Executable file
View File

@ -0,0 +1,2 @@
nix-prefetch-git --leave-dotGit https://github.com/vpsfreecz/nixpkgs $1 > nixpkgs-vpsfreecz.json
cat nixpkgs-vpsfreecz.json

2
pinned/pin_vpsadminos Executable file
View File

@ -0,0 +1,2 @@
nix-prefetch-git --leave-dotGit https://github.com/vpsfreecz/vpsadminos $1 > vpsadminos.json
cat vpsadminos.json

7
pinned/vpsadminos.json Normal file
View File

@ -0,0 +1,7 @@
{
"url": "https://github.com/vpsfreecz/vpsadminos",
"rev": "5de1aee04cb5a88887a4e6db582ef9cd6f3542aa",
"date": "2018-08-02T02:36:34+02:00",
"sha256": "0mbc4c5958ny9l8wfk2nv5jai0a3dxd37nnfkrhjj0i1hlgljg47",
"fetchSubmodules": true
}