2022-05-21 00:07:49 +00:00
|
|
|
# docs:
|
|
|
|
# https://nixos.wiki/wiki/Flakes
|
|
|
|
# https://serokell.io/blog/practical-nix-flakes
|
|
|
|
|
|
|
|
{
|
|
|
|
inputs = {
|
2022-05-28 19:35:43 +00:00
|
|
|
nixpkgs.url = "nixpkgs/nixos-22.05";
|
2022-05-25 03:57:43 +00:00
|
|
|
# pkgs-telegram.url = "nixpkgs/33775ec9a2173a08e46edf9f46c9febadbf743e8";# 2022/04/18; telegram 3.7.3. fails: nix log /nix/store/y5kv47hnv55qknb6cnmpcyraicay79fx-telegram-desktop-3.7.3.drv: g++: fatal error: cannot execute '/nix/store/njk5sbd21305bhr7gwibxbbvgbx5lxvn-gcc-9.3.0/libexec/gcc/aarch64-unknown-linux-gnu/9.3.0/cc1plus': execv: No such file or directory
|
2022-05-23 02:45:54 +00:00
|
|
|
mobile-nixos = {
|
2022-05-24 05:47:32 +00:00
|
|
|
url = "github:nixos/mobile-nixos";
|
|
|
|
flake = false;
|
2022-05-23 02:45:54 +00:00
|
|
|
};
|
2022-05-22 01:05:32 +00:00
|
|
|
home-manager = {
|
2022-06-03 08:39:34 +00:00
|
|
|
url = "github:nix-community/home-manager/release-22.05";
|
2022-05-22 01:05:32 +00:00
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
2022-05-22 11:03:30 +00:00
|
|
|
nurpkgs.url = "github:nix-community/NUR";
|
2022-06-06 23:36:22 +00:00
|
|
|
sops-nix.url = "github:Mic92/sops-nix";
|
2022-06-20 10:28:01 +00:00
|
|
|
impermanence.url = "github:nix-community/impermanence";
|
2022-05-21 00:07:49 +00:00
|
|
|
};
|
2022-05-21 07:30:29 +00:00
|
|
|
|
2022-06-23 22:57:20 +00:00
|
|
|
outputs = { self, nixpkgs, mobile-nixos, home-manager, nurpkgs, sops-nix, impermanence }:
|
|
|
|
let
|
2022-06-24 06:26:51 +00:00
|
|
|
patchedPkgs = system: nixpkgs.legacyPackages.${system}.applyPatches {
|
|
|
|
name = "nixpkgs-patched-uninsane";
|
|
|
|
src = nixpkgs;
|
|
|
|
patches = import ./nixpatches/list.nix nixpkgs.legacyPackages.${system}.fetchpatch;
|
|
|
|
};
|
|
|
|
# return something which behaves like `pkgs`, for the provided system
|
|
|
|
nixpkgsFor = system: import (patchedPkgs system) { inherit system; };
|
|
|
|
# evaluate ONLY our overlay, for the provided system
|
|
|
|
customPackagesFor = system: import ./pkgs/overlay.nix (nixpkgsFor system) (nixpkgsFor system);
|
2022-06-23 22:57:20 +00:00
|
|
|
decl-machine = { name, system }:
|
|
|
|
let
|
2022-06-24 06:26:51 +00:00
|
|
|
nixosSystem = import ((patchedPkgs system) + "/nixos/lib/eval-config.nix");
|
2022-06-23 22:57:20 +00:00
|
|
|
in (nixosSystem {
|
|
|
|
inherit system;
|
|
|
|
specialArgs = { inherit nixpkgs mobile-nixos home-manager nurpkgs impermanence; };
|
|
|
|
modules = [
|
|
|
|
./modules
|
|
|
|
./machines/${name}
|
|
|
|
(import ./helpers/set-hostname.nix name)
|
|
|
|
sops-nix.nixosModules.sops
|
|
|
|
{
|
|
|
|
nixpkgs.config.allowUnfree = true;
|
|
|
|
nixpkgs.overlays = [
|
|
|
|
nurpkgs.overlay
|
|
|
|
(import "${mobile-nixos}/overlay/overlay.nix")
|
|
|
|
(import ./pkgs/overlay.nix)
|
|
|
|
];
|
|
|
|
}
|
|
|
|
];
|
2022-05-21 07:40:56 +00:00
|
|
|
});
|
|
|
|
|
2022-06-23 22:53:35 +00:00
|
|
|
decl-bootable-machine = { name, system }: rec {
|
2022-06-23 22:57:20 +00:00
|
|
|
nixosConfiguration = decl-machine { inherit name system; };
|
2022-06-23 22:53:35 +00:00
|
|
|
# this produces a EFI-bootable .img file (GPT with a /boot partition and a system (/ or /nix) partition).
|
|
|
|
# after building this:
|
2022-06-24 23:04:25 +00:00
|
|
|
# - flash it to a bootable medium (SD card, flash drive, HDD)
|
|
|
|
# - resize the root partition (use cfdisk)
|
|
|
|
# - mount the part
|
|
|
|
# chown root:nixblkd <part>/nix/store
|
|
|
|
# chmod 775 <part>/nix/store
|
|
|
|
# chown root:root -R <part>/nix/store/*
|
|
|
|
# populate any important things (persist/, home/colin/.ssh, etc)
|
2022-06-23 22:53:35 +00:00
|
|
|
# - boot
|
2022-06-24 23:04:25 +00:00
|
|
|
# - if fs wasn't resized automatically, then `sudo btrfs filesystem resize max /`
|
2022-06-23 22:53:35 +00:00
|
|
|
# - checkout this flake into /etc/nixos AND UPDATE THE FS UUIDS.
|
|
|
|
# - `nixos-rebuild --flake './#<machine>' switch`
|
|
|
|
img = nixosConfiguration.config.system.build.img;
|
2022-05-24 00:15:38 +00:00
|
|
|
};
|
2022-06-23 22:57:20 +00:00
|
|
|
machines.servo = decl-bootable-machine { name = "servo"; system = "aarch64-linux"; };
|
|
|
|
machines.desko = decl-bootable-machine { name = "desko"; system = "x86_64-linux"; };
|
|
|
|
machines.lappy = decl-bootable-machine { name = "lappy"; system = "x86_64-linux"; };
|
|
|
|
machines.moby = decl-bootable-machine { name = "moby"; system = "aarch64-linux"; };
|
|
|
|
in {
|
|
|
|
nixosConfigurations = builtins.mapAttrs (name: value: value.nixosConfiguration) machines;
|
|
|
|
imgs = builtins.mapAttrs (name: value: value.img) machines;
|
2022-06-24 06:26:51 +00:00
|
|
|
packages.x86_64-linux = customPackagesFor "x86_64-linux";
|
|
|
|
packages.aarch64-linux = customPackagesFor "aarch64-linux";
|
2022-05-21 00:07:49 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|