From 0eacaed516aa83b89d20836d48b93be8a6fa413c Mon Sep 17 00:00:00 2001 From: Fiscal Velvet Poet Date: Tue, 19 Jul 2022 08:20:05 +1000 Subject: [PATCH] nix: initial flake devshell --- .envrc | 4 +- flake.lock | 182 +++++++++++++++++++++++++++++++++++++++ flake.nix | 13 +++ modules/modules-list.nix | 2 + nixos/configurations.nix | 37 ++++++++ outputs.nix | 27 ++++++ shell.nix | 16 ++++ 7 files changed, 279 insertions(+), 2 deletions(-) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 modules/modules-list.nix create mode 100644 nixos/configurations.nix create mode 100644 outputs.nix create mode 100644 shell.nix diff --git a/.envrc b/.envrc index 18f695a..005a801 100644 --- a/.envrc +++ b/.envrc @@ -1,2 +1,2 @@ -use nix -watch_file nix/* +use flake +watch_file flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..bf96bc2 --- /dev/null +++ b/flake.lock @@ -0,0 +1,182 @@ +{ + "nodes": { + "lowdown-src": { + "flake": false, + "locked": { + "lastModified": 1633514407, + "narHash": "sha256-Dw32tiMjdK9t3ETl5fzGrutQTzh2rufgZV4A/BbxuD4=", + "owner": "kristapsdz", + "repo": "lowdown", + "rev": "d2c2b44ff6c27b936ec27358a2653caaef8f73b8", + "type": "github" + }, + "original": { + "owner": "kristapsdz", + "repo": "lowdown", + "type": "github" + } + }, + "nix": { + "inputs": { + "lowdown-src": "lowdown-src", + "nixpkgs": "nixpkgs", + "nixpkgs-regression": "nixpkgs-regression" + }, + "locked": { + "lastModified": 1657886512, + "narHash": "sha256-B9EyDUz/9tlcWwf24lwxCFmkxuPTVW7HFYvp0C4xGbc=", + "owner": "NixOS", + "repo": "nix", + "rev": "0b62dab6db3da5b20e62697b14aaaf80f1a2eea6", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "2.10.3", + "repo": "nix", + "type": "github" + } + }, + "nixops": { + "inputs": { + "nixpkgs": "nixpkgs_2", + "utils": "utils" + }, + "locked": { + "lastModified": 1657388807, + "narHash": "sha256-MtTM5KUHIDqnY254chIOp00EmsbYsXR3mXrnbbY4wg0=", + "owner": "NixOS", + "repo": "nixops", + "rev": "dcafae5258773dc0fbdd31b425f1ad3fb59173fe", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "master", + "repo": "nixops", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1657693803, + "narHash": "sha256-G++2CJ9u0E7NNTAi9n5G8TdDmGJXcIjkJ3NF8cetQB8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "365e1b3a859281cf11b94f87231adeabbdd878a2", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-22.05-small", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-regression": { + "locked": { + "lastModified": 1643052045, + "narHash": "sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", + "type": "github" + } + }, + "nixpkgsUnstable": { + "locked": { + "lastModified": 1658103945, + "narHash": "sha256-1/kQlzKGt1563JZ+gIlNHU6rEbaDh2KopZLJ4CzraWI=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "2e3f6efdeda4cfff0259912495761885d8bee74a", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1656753965, + "narHash": "sha256-BCrB3l0qpJokOnIVc3g2lHiGhnjUi0MoXiw6t1o8H1E=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "0ea7a8f1b939d74e5df8af9a8f7342097cdf69eb", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1657972522, + "narHash": "sha256-JTiKsBT1BwMbtSUsvtSl8ffkiirby8FaujJVGV766Q8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "07a2e6a4e31ea48408861607198972d60adaf4ad", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-22.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nix": "nix", + "nixops": "nixops", + "nixpkgs": "nixpkgs_3", + "nixpkgsUnstable": "nixpkgsUnstable", + "utils": "utils_2" + } + }, + "utils": { + "locked": { + "lastModified": 1634851050, + "narHash": "sha256-N83GlSGPJJdcqhUxSCS/WwW5pksYf3VP1M13cDRTSVA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c91f3de5adaf1de973b797ef7485e441a65b8935", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "utils_2": { + "locked": { + "lastModified": 1656928814, + "narHash": "sha256-RIFfgBuKz6Hp89yRr7+NR5tzIAbn52h8vT6vXkYjZoM=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "7e2a3b3dfd9af950a856d66b0a7d01e3c18aa249", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..552447a --- /dev/null +++ b/flake.nix @@ -0,0 +1,13 @@ +{ + description = "jfdic-ops deployment"; + + inputs = { + nix.url = "github:NixOS/nix/?ref=2.10.3"; + nixops.url = github:NixOS/nixops/?ref=master; + nixpkgs.url = github:NixOS/nixpkgs/?ref=nixos-22.05; + nixpkgsUnstable.url = github:NixOS/nixpkgs/?ref=nixos-unstable; + utils.url = "github:numtide/flake-utils"; + }; + + outputs = {...} @ args: import ./outputs.nix args; +} diff --git a/modules/modules-list.nix b/modules/modules-list.nix new file mode 100644 index 0000000..0d4f101 --- /dev/null +++ b/modules/modules-list.nix @@ -0,0 +1,2 @@ +[ +] diff --git a/nixos/configurations.nix b/nixos/configurations.nix new file mode 100644 index 0000000..65945ab --- /dev/null +++ b/nixos/configurations.nix @@ -0,0 +1,37 @@ +{ + self, + nixpkgs, + inputs, + nix, + ... +}: let + nixosSystem = nixpkgs.lib.makeOverridable nixpkgs.lib.nixosSystem; + customModules = import ../modules/modules-list.nix; + baseModules = [ + # make flake inputs accessiable in NixOS + {_module.args.inputs = inputs;} + { + imports = [ + ({pkgs, ...}: { + nix.nixPath = [ + "nixpkgs=${pkgs.path}" + ]; + nix.extraOptions = '' + experimental-features = nix-command flakes + ''; + documentation.info.enable = false; + }) + ]; + } + ]; + defaultModules = baseModules ++ customModules; +in { + dionach = nixosSystem { + system = "x86_64-linux"; + modules = + defaultModules + ++ [ + #./hosts/toscano/configuration.nix + ]; + }; +} diff --git a/outputs.nix b/outputs.nix new file mode 100644 index 0000000..99f2b92 --- /dev/null +++ b/outputs.nix @@ -0,0 +1,27 @@ +{ + self, + nix, + nixops, + nixpkgs, + nixpkgsUnstable, + utils, + ... +} @ inputs: +(utils.lib.eachDefaultSystem (system: let + pkgs = + nixpkgs.legacyPackages."${system}"; +in { + devShell = + pkgs.callPackage + ./shell.nix { + inherit (nix.packages."${pkgs.system}") nix; + inherit (nixpkgsUnstable.legacyPackages."${pkgs.system}") alejandra; + nixops = nixops.defaultPackage."${pkgs.system}"; + }; +})) +// { + nixosConfigurations = import ./nixos/configurations.nix (inputs + // { + inherit inputs; + }); +} diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..d1f5116 --- /dev/null +++ b/shell.nix @@ -0,0 +1,16 @@ +{ + pkgs ? import {}, + alejandra, + mkShell, + nixops, + nix, +}: +with pkgs; + mkShell { + buildInputs = [ + alejandra # The Uncompromising Nix Code Formatter + nixops + nix + treefmt # one CLI to format the code tree + ]; + }