diff options
author | Ben Sima <ben@bsima.me> | 2025-01-02 16:20:21 -0500 |
---|---|---|
committer | Ben Sima <ben@bsima.me> | 2025-01-02 16:20:21 -0500 |
commit | 0fb4ae72c5754761fd7666e4274f4beef0484c32 (patch) | |
tree | d8820c808f31f287c3fcc266c02e3a26ddcdfbc3 /Omni/Bild.nix | |
parent | 3790d334c994db7a0e1eac9c130c2b1316c78c35 (diff) |
Switch to alejandra for nix formatting
I mostly wanted a formatter that would format `inherit` blocks
vertically, because otherwise they are super hard to read when diffing
or even just editing. Both alejandra and the new nixos/nixfmt format
verically like this, but alejandra has slightly better format (I guess)
and for some reason nixfmt did not respect my `GLOBIGNORE` setting when
doing `nixfmt **/*.nix` so it was trying to format stuff in `_/nix`, and
failed. So anyway I went with alejandra.
- https://github.com/kamadorueda/alejandra
- https://discourse.nixos.org/t/enforcing-nix-formatting-in-nixpkgs/49506
Diffstat (limited to 'Omni/Bild.nix')
-rw-r--r-- | Omni/Bild.nix | 109 |
1 files changed, 76 insertions, 33 deletions
diff --git a/Omni/Bild.nix b/Omni/Bild.nix index fdfa3b8..f36f8f9 100644 --- a/Omni/Bild.nix +++ b/Omni/Bild.nix @@ -1,14 +1,24 @@ -{ nixpkgs ? import ./Bild/Nixpkgs.nix }: - -let +{nixpkgs ? import ./Bild/Nixpkgs.nix}: let constants = import ./Bild/Constants.nix; # expose some attrs from stable, keep this minimal and simple - stable = let stable = nixpkgs.nixos-24_11; + stable = let + stable = nixpkgs.nixos-24_11; in { - inherit (stable) - sources lib makeWrapper ccacheStdenv haskell sbcl python312 nixos mkShell - dockerTools pkgs; + inherit + (stable) + sources + lib + makeWrapper + ccacheStdenv + haskell + sbcl + python312 + nixos + mkShell + dockerTools + pkgs + ; stdenv = stable.ccacheStdenv; }; @@ -19,13 +29,16 @@ let # makeSourcesPath :: [pkgset] -> str makeSourcesPath = with stable; sources: - lib.trivial.pipe sources [ - (builtins.map lib.attrsets.attrValues) - lib.lists.flatten - (builtins.filter (pkg: pkg != null)) - (builtins.map (pkg: if pkg ? src then pkg.src else pkg)) - (lib.strings.concatStringsSep ":") - ]; + lib.trivial.pipe sources [ + (builtins.map lib.attrsets.attrValues) + lib.lists.flatten + (builtins.filter (pkg: pkg != null)) + (builtins.map (pkg: + if pkg ? src + then pkg.src + else pkg)) + (lib.strings.concatStringsSep ":") + ]; # this is the main library definitions, recursive references can be made with # `self.thing`, like in Python objects @@ -42,7 +55,8 @@ let # all available packages deps = import ./Bild/Deps/Haskell.nix; - packages = self.lib.attrsets.getAttrs self.haskell.deps + packages = + self.lib.attrsets.getAttrs self.haskell.deps stable.haskell.packages."${constants.ghcCompiler}"; # make a ghc with dependencies @@ -78,10 +92,11 @@ let ]); }; - lisp = { sbclWith = stable.sbcl.withPackages; }; + lisp = {sbclWith = stable.sbcl.withPackages;}; python = { - packages = self.lib.attrsets.getAttrs (import ./Bild/Deps/Python.nix) + packages = + self.lib.attrsets.getAttrs (import ./Bild/Deps/Python.nix) stable.python312.pkgs; pythonWith = stable.python312.withPackages; buildPythonApplication = stable.python312.pkgs.buildPythonApplication; @@ -93,9 +108,34 @@ let # exposed packages for inclusion in builds pkgs = with stable.pkgs; { - inherit bat bc cmark universal-ctags datasette deadnix fd figlet fzf git - git-branchless gitlint groff guile hlint indent jq lolcat mypy nixfmt - ormolu pkg-config ripgrep rustc tree wemux; + inherit + alejandra + bat + bc + cmark + universal-ctags + datasette + deadnix + fd + figlet + fzf + git + git-branchless + gitlint + groff + guile + hlint + indent + jq + lolcat + mypy + ormolu + pkg-config + ripgrep + rustc + tree + wemux + ; llama-cpp = unstable.llama-cpp; # can't put this in the dev namespace because it pulls in openai with # python311, which conflicts with any other usage of openai with @@ -124,18 +164,18 @@ let ../Omni/Test.hs ]; }; - nativeBuildInputs = [ self.haskell.ghcPackageSetBild ]; - buildInputs = [ self.makeWrapper ]; + nativeBuildInputs = [self.haskell.ghcPackageSetBild]; + buildInputs = [self.makeWrapper]; propagatedBuildInputs = with self.pkgs; [ pkg-config git # this is just to get access to ghc-pkg in bild - (self.haskell.ghcWith (_: [ ])) + (self.haskell.ghcWith (_: [])) # lisp deps, remove this when i implement nix builds for lisp guile (self.lisp.sbclWith - (p: with p; [ alexandria ])) # just enough to build Example.lisp + (p: with p; [alexandria])) # just enough to build Example.lisp ]; strictDeps = true; ghcVersion = self.haskell.ghcVersion; @@ -158,11 +198,11 @@ let installPhase = '' wrapProgram $out/bin/bild \ --prefix PATH : ${ - self.lib.makeBinPath [ - self.haskell.ghcPackageSetBild - self.pkgs.git - ] - } \ + self.lib.makeBinPath [ + self.haskell.ghcPackageSetBild + self.pkgs.git + ] + } \ --set GHC_PACKAGE_PATH \ $out/lib/ghc-$ghcVersion/package.conf.d ''; @@ -177,7 +217,8 @@ let HOSTNAME = "nix-sandbox"; # we need to remove the $src root because bild expects paths relative to the # working directory: - TARGET = "." + TARGET = + "." + self.lib.strings.removePrefix (toString src) (toString target); buildPhase = '' export CODEROOT=$(pwd) @@ -242,14 +283,16 @@ let # build an os image for a digital ocean droplet droplet = cfg: - (stable.nixos ({ modulesPath, ... }: { + (stable.nixos ({modulesPath, ...}: { imports = [ "${toString modulesPath}/virtualisation/digital-ocean-image.nix" (_args: cfg) ]; - })).digitalOceanImage; + })) + .digitalOceanImage; # build a docker image image = stable.dockerTools.buildImage; }; -in self +in + self |