lib

Core libraries for Radroots
git clone https://radroots.dev/git/lib.git
Log | Files | Refs | README

flake.nix (3880B)


      1 {
      2   description = "Radroots Core Libraries";
      3 
      4   inputs = {
      5     nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
      6     flake-parts.url = "github:hercules-ci/flake-parts";
      7     crane.url = "github:ipetkov/crane";
      8     rust-overlay = {
      9       url = "github:oxalica/rust-overlay";
     10       inputs.nixpkgs.follows = "nixpkgs";
     11     };
     12     treefmt-nix = {
     13       url = "github:numtide/treefmt-nix";
     14       inputs.nixpkgs.follows = "nixpkgs";
     15     };
     16   };
     17 
     18   outputs =
     19     inputs@{
     20       self,
     21       flake-parts,
     22       ...
     23     }:
     24     flake-parts.lib.mkFlake { inherit inputs; } {
     25       imports = [ inputs.treefmt-nix.flakeModule ];
     26       systems = import ./build/nix/service/systems.nix;
     27 
     28       flake.lib = {
     29         supportedSystems = import ./build/nix/service/systems.nix;
     30         mkServiceHelpers =
     31           system:
     32           assert inputs.nixpkgs.lib.assertMsg (builtins.elem system (
     33             import ./build/nix/service/systems.nix
     34           )) "service helpers support only the governed Nix systems";
     35           let
     36             pkgs = import inputs.nixpkgs {
     37               inherit system;
     38               overlays = [ inputs.rust-overlay.overlays.default ];
     39             };
     40           in
     41           import ./build/nix/service {
     42             crane = inputs.crane;
     43             lib = inputs.nixpkgs.lib;
     44             inherit pkgs;
     45           };
     46       };
     47 
     48       flake.overlays.default = final: _previous: {
     49         radroots-lib =
     50           assert inputs.nixpkgs.lib.assertMsg
     51             (builtins.elem final.stdenv.hostPlatform.system self.lib.supportedSystems)
     52             "the Radroots Lib overlay supports only the governed Nix systems";
     53           self.packages.${final.stdenv.hostPlatform.system}.default;
     54       };
     55 
     56       perSystem =
     57         {
     58           config,
     59           lib,
     60           system,
     61           ...
     62         }:
     63         let
     64           pkgs = import inputs.nixpkgs {
     65             inherit system;
     66             overlays = [ inputs.rust-overlay.overlays.default ];
     67           };
     68           service = import ./build/nix/service {
     69             crane = inputs.crane;
     70             inherit lib pkgs;
     71           };
     72           toolchains = {
     73             stable = service.mkToolchain {
     74               rustToolchainFile = ./rust-toolchain.toml;
     75             };
     76             coverage = service.mkToolchain {
     77               rustToolchainFile = ./rust-toolchain-coverage.toml;
     78             };
     79           };
     80           common = import ./build/nix/common.nix {
     81             crane = inputs.crane;
     82             inherit lib pkgs toolchains;
     83           };
     84           library = import ./build/nix/library.nix {
     85             inherit lib pkgs;
     86             inherit (common) version;
     87           };
     88           serviceFixture = import ./build/nix/service/fixture.nix {
     89             inherit lib pkgs service;
     90             nixosSystem = inputs.nixpkgs.lib.nixosSystem;
     91             toolchain = toolchains.stable;
     92           };
     93           fixtureChecks = lib.mapAttrs' (
     94             name: value: lib.nameValuePair "service-fixture-${name}" value
     95           ) serviceFixture.outputs.checks;
     96         in
     97         {
     98           treefmt = import ./treefmt.nix;
     99 
    100           apps = {
    101             default = library.app;
    102           }
    103           // (import ./build/nix/apps.nix {
    104             inherit
    105               common
    106               config
    107               lib
    108               pkgs
    109               toolchains
    110               ;
    111           });
    112 
    113           checks = lib.filterAttrs (_: value: value != null) (
    114             (import ./build/nix/checks.nix {
    115               inherit common pkgs;
    116             })
    117             // fixtureChecks
    118             // {
    119               release-bundle = library.check;
    120             }
    121           );
    122 
    123           devShells = import ./build/nix/devshells.nix {
    124             inherit common pkgs toolchains;
    125           };
    126 
    127           packages = {
    128             default = library.package;
    129             xtask = common.xtaskPackage;
    130           };
    131         };
    132     };
    133 }