nix-files/flake.nix

88 lines
3.8 KiB
Nix
Raw Normal View History

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";
# 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
mobile-nixos = {
url = "github:nixos/mobile-nixos";
flake = false;
};
home-manager = {
url = "github:nix-community/home-manager/release-22.05";
inputs.nixpkgs.follows = "nixpkgs";
};
nurpkgs.url = "github:nix-community/NUR";
2022-06-06 23:36:22 +00:00
sops-nix.url = "github:Mic92/sops-nix";
impermanence.url = "github:nix-community/impermanence";
2022-05-21 00:07:49 +00:00
};
outputs = { self, nixpkgs, mobile-nixos, home-manager, nurpkgs, sops-nix, impermanence }: {
2022-06-12 22:11:41 +00:00
machines.servo = self.decl-bootable-machine { name = "servo"; 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"; };
machines.moby = self.decl-bootable-machine { name = "moby"; system = "aarch64-linux"; };
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-06-23 22:49:59 +00:00
decl-machine = { name, system }: let
patchedPkgs = nixpkgs.legacyPackages.${system}.applyPatches {
name = "nixpkgs-patched-uninsane";
2022-06-23 22:49:59 +00:00
src = nixpkgs;
patches = [
# phosh: allow fractional scaling
2022-06-23 22:49:59 +00:00
(nixpkgs.legacyPackages.${system}.fetchpatch {
url = "https://github.com/NixOS/nixpkgs/pull/175872.diff";
sha256 = "sha256-mEmqhe8DqlyCxkFWQKQZu+2duz69nOkTANh9TcjEOdY=";
})
# for raspberry pi: allow building u-boot for rpi 4{,00}
# TODO: remove after upstreamed: https://github.com/NixOS/nixpkgs/pull/176018
./nixpatches/02-rpi4-uboot.patch
# alternative to https://github.com/NixOS/nixpkgs/pull/173200
./nixpatches/04-dart-2.7.0.patch
# whalebird: suuport aarch64
2022-06-23 22:49:59 +00:00
(nixpkgs.legacyPackages.${system}.fetchpatch {
url = "https://github.com/NixOS/nixpkgs/pull/176476.diff";
sha256 = "sha256-126DljM06hqPZ3fjLZ3LBZR64nFbeTfzSazEu72d4y8=";
})
2022-06-07 09:33:11 +00:00
# TODO: upstream
./nixpatches/07-duplicity-rich-url.patch
];
};
nixosSystem = import (patchedPkgs + "/nixos/lib/eval-config.nix");
in (nixosSystem {
inherit system;
specialArgs = { inherit nixpkgs mobile-nixos home-manager nurpkgs impermanence; };
2022-05-21 07:40:56 +00:00
modules = [
2022-06-07 00:35:28 +00:00
./modules
./machines/${name}
2022-05-24 03:20:05 +00:00
(import ./helpers/set-hostname.nix name)
2022-06-06 23:36:22 +00:00
sops-nix.nixosModules.sops
{
nixpkgs.config.allowUnfree = true;
nixpkgs.overlays = [
nurpkgs.overlay
(import "${mobile-nixos}/overlay/overlay.nix")
(import ./pkgs/overlay.nix)
];
}
2022-06-23 22:49:59 +00:00
];
2022-05-21 07:40:56 +00:00
});
2022-06-23 22:53:35 +00:00
decl-bootable-machine = { name, system }: rec {
nixosConfiguration = self.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:
# - flash it to a bootable medium (SD card, flash drive)
# - boot
# - checkout this flake into /etc/nixos AND UPDATE THE FS UUIDS.
# - `nixos-rebuild --flake './#<machine>' switch`
img = nixosConfiguration.config.system.build.img;
};
2022-05-21 00:07:49 +00:00
};
}