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-05-21 00:07:49 +00:00
|
|
|
};
|
2022-05-21 07:30:29 +00:00
|
|
|
|
2022-06-06 23:36:22 +00:00
|
|
|
outputs = { self, nixpkgs, mobile-nixos, home-manager, nurpkgs, sops-nix }: {
|
2022-05-22 21:39:52 +00:00
|
|
|
machines.uninsane = self.decl-bootable-machine { name = "uninsane"; system = "aarch64-linux"; };
|
|
|
|
machines.desko = self.decl-bootable-machine { name = "desko"; system = "x86_64-linux"; };
|
|
|
|
machines.lappy = self.decl-bootable-machine { name = "lappy"; system = "x86_64-linux"; };
|
2022-05-22 08:27:02 +00:00
|
|
|
|
2022-05-24 07:53:13 +00:00
|
|
|
machines.moby =
|
|
|
|
let machine = self.decl-machine {
|
|
|
|
name = "moby";
|
2022-05-22 21:39:52 +00:00
|
|
|
system = "aarch64-linux";
|
2022-05-24 07:53:13 +00:00
|
|
|
extraModules = [
|
2022-05-24 05:47:32 +00:00
|
|
|
(import "${mobile-nixos}/lib/configuration.nix" {
|
|
|
|
device = "pine64-pinephone";
|
2022-05-22 21:39:52 +00:00
|
|
|
})
|
|
|
|
];
|
|
|
|
};
|
2022-05-24 07:53:13 +00:00
|
|
|
in {
|
|
|
|
nixosConfiguration = machine;
|
|
|
|
img = machine.config.mobile.outputs.u-boot.disk-image;
|
|
|
|
};
|
2022-05-22 01:05:32 +00:00
|
|
|
|
2022-05-22 22:11:08 +00:00
|
|
|
nixosConfigurations = builtins.mapAttrs (name: value: value.nixosConfiguration) self.machines;
|
|
|
|
imgs = builtins.mapAttrs (name: value: value.img) self.machines;
|
2022-05-21 07:30:29 +00:00
|
|
|
|
2022-06-01 10:28:49 +00:00
|
|
|
decl-machine = { name, system, extraModules ? [], basePkgs ? nixpkgs }: let
|
|
|
|
patchedPkgs = basePkgs.legacyPackages.${system}.applyPatches {
|
|
|
|
name = "nixpkgs-patched-uninsane";
|
|
|
|
src = basePkgs;
|
|
|
|
patches = [
|
2022-06-06 04:19:03 +00:00
|
|
|
# phosh: allow fractional scaling
|
|
|
|
(basePkgs.legacyPackages.${system}.fetchpatch {
|
|
|
|
url = "https://github.com/NixOS/nixpkgs/pull/175872.diff";
|
|
|
|
sha256 = "sha256-mEmqhe8DqlyCxkFWQKQZu+2duz69nOkTANh9TcjEOdY=";
|
|
|
|
})
|
2022-06-02 21:18:41 +00:00
|
|
|
# for raspberry pi: allow building u-boot for rpi 4{,00}
|
2022-06-06 04:19:03 +00:00
|
|
|
# TODO: remove after upstreamed: https://github.com/NixOS/nixpkgs/pull/176018
|
2022-06-02 21:18:41 +00:00
|
|
|
./nixpatches/02-rpi4-uboot.patch
|
2022-06-06 04:19:03 +00:00
|
|
|
# alternative to https://github.com/NixOS/nixpkgs/pull/173200
|
2022-06-05 09:28:23 +00:00
|
|
|
./nixpatches/04-dart-2.7.0.patch
|
2022-06-06 04:19:03 +00:00
|
|
|
# TODO: remove after upstreamed: https://github.com/NixOS/nixpkgs/pull/176476
|
2022-06-06 04:25:58 +00:00
|
|
|
./nixpatches/06-whalebird-4.6.0-aarch64.patch
|
2022-06-01 10:28:49 +00:00
|
|
|
];
|
|
|
|
};
|
|
|
|
nixosSystem = import (patchedPkgs + "/nixos/lib/eval-config.nix");
|
|
|
|
in (nixosSystem {
|
2022-05-22 21:39:52 +00:00
|
|
|
inherit system;
|
2022-05-27 06:52:08 +00:00
|
|
|
specialArgs = { inherit home-manager; inherit nurpkgs; secrets = import ./secrets/default.nix; };
|
2022-05-21 07:40:56 +00:00
|
|
|
modules = [
|
|
|
|
./configuration.nix
|
2022-06-07 00:35:28 +00:00
|
|
|
./modules
|
2022-05-24 00:15:38 +00:00
|
|
|
./machines/${name}
|
2022-05-24 03:20:05 +00:00
|
|
|
(import ./helpers/set-hostname.nix name)
|
2022-05-24 07:45:55 +00:00
|
|
|
(self.overlaysModule system)
|
2022-06-06 23:36:22 +00:00
|
|
|
sops-nix.nixosModules.sops
|
2022-05-21 07:40:56 +00:00
|
|
|
] ++ extraModules;
|
|
|
|
});
|
|
|
|
|
2022-05-22 08:38:19 +00:00
|
|
|
# this produces a EFI-bootable .img file (GPT with / and /boot).
|
|
|
|
# after building this, steps are:
|
|
|
|
# run `btrfs-convert --uuid copy <device>`
|
|
|
|
# boot, checkout this flake into /etc/nixos AND UPDATE THE UUIDS IT REFERENCES.
|
|
|
|
# then `nixos-rebuild ...`
|
2022-05-24 00:15:38 +00:00
|
|
|
decl-img = { name, system, extraModules ? [] }: (
|
|
|
|
(self.decl-machine { inherit name; inherit system; extraModules = extraModules ++ [./image.nix]; })
|
2022-05-22 20:35:04 +00:00
|
|
|
.config.system.build.raw
|
2022-05-22 08:38:19 +00:00
|
|
|
);
|
|
|
|
|
2022-05-24 00:15:38 +00:00
|
|
|
decl-bootable-machine = { name, system }: {
|
|
|
|
nixosConfiguration = self.decl-machine { inherit name; inherit system; };
|
|
|
|
img = self.decl-img { inherit name; inherit system; };
|
|
|
|
};
|
2022-05-22 21:39:52 +00:00
|
|
|
|
2022-05-24 07:45:55 +00:00
|
|
|
overlaysModule = system: { config, pkgs, ...}: {
|
|
|
|
nixpkgs.config.allowUnfree = true;
|
|
|
|
|
|
|
|
nixpkgs.overlays = [
|
|
|
|
#mobile-nixos.overlay
|
|
|
|
nurpkgs.overlay
|
|
|
|
(next: prev: {
|
|
|
|
#### customized packages
|
|
|
|
# nixos-unstable pleroma is too far out-of-date for our db
|
|
|
|
pleroma = prev.callPackage ./pkgs/pleroma { };
|
|
|
|
# jackett doesn't allow customization of the bind address: this will probably always be here.
|
|
|
|
jackett = next.callPackage ./pkgs/jackett { pkgs = prev; };
|
|
|
|
# fix abrupt HDD poweroffs as during reboot. patching systemd requires rebuilding nearly every package.
|
|
|
|
# systemd = import ./pkgs/systemd { pkgs = prev; };
|
|
|
|
|
|
|
|
# patch rpi uboot with something that fixes USB HDD boot
|
|
|
|
ubootRaspberryPi4_64bit = next.callPackage ./pkgs/ubootRaspberryPi4_64bit { pkgs = prev; };
|
|
|
|
|
2022-05-25 03:57:43 +00:00
|
|
|
#### TEMPORARY NIXOS-UNSTABLE PACKAGES
|
2022-05-24 07:45:55 +00:00
|
|
|
|
2022-06-01 23:12:06 +00:00
|
|
|
# stable telegram doesn't build, so explicitly use the stable one.
|
2022-05-25 03:57:43 +00:00
|
|
|
# TODO: apply this specifically to the moby build?
|
|
|
|
# tdesktop = pkgs-telegram.legacyPackages.${system}.tdesktop;
|
|
|
|
tdesktop = nixpkgs.legacyPackages.${system}.tdesktop;
|
2022-06-04 09:05:20 +00:00
|
|
|
|
|
|
|
#### TEMPORARY: PACKAGES WAITING TO BE UPSTREAMED
|
2022-06-05 21:53:57 +00:00
|
|
|
# whalebird = prev.callPackage ./pkgs/whalebird { };
|
2022-06-05 09:28:23 +00:00
|
|
|
kaiteki = prev.callPackage ./pkgs/kaiteki { };
|
2022-05-24 07:45:55 +00:00
|
|
|
})
|
|
|
|
];
|
|
|
|
};
|
2022-05-21 00:07:49 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|