Skip to content

Improved flake support #129

@colinxs

Description

@colinxs

I recently came across Arion and it's been fantastic. Thanks for making this package!

The only thing I've come across that's a bit awkward is the need to have arion-compose.nix and arion-pkgs.nix when using nixUnstable/flakes. Currently I have a dozen arion-{compose,pkgs}.nix scattered about that only contain a single line:

arion-pkgs.nix:

(builtins.getFlake (toString ./.)).legacyPackages.x86_64-linux

arion-compose.nix

(builtins.getFlake (toString ./.)).packages.x86_64-linux.arion-compose

Instead, it would be awesome if the following was possible:

arion --flake .#arion --flake /home/colinxs/fooflake#arion-foo up

This mimics the flake interface for nixos-rebuild, home-manager, and other tools in the Nix ecosystem.

Each flake.nix would look something like:

{
  inputs.nixpkgs.url = "nixpkgs/nixos-unstable";
  inputs.flake-utils.url = "github:numtide/flake-utils";
  outputs = { self, nixpkgs, flake-utils }:
    flake-utils.lib.eachSystem [ "x86_64-linux" ] (system:
      let pkgs = nixpkgs.legacyPackages."${system}";
      in
      {
        packages.arion = {
          inherit pkgs;
          config = { pkgs, ... }: {
            config.services = {
              webserver = {
                service.useHostStore = true;
                service.command = [
                  "sh"
                  "-c"
                  ''
                    cd "$$WEB_ROOT"
                    ${pkgs.python3}/bin/python -m http.server
                  ''
                ];
                service.ports = [
                  "8000:8000" # host:container
                ];
                service.environment.WEB_ROOT =
                  "${pkgs.nix.doc}/share/doc/nix/manual";
              };
            };
          };
        };
      });
}

Now everything is fully contained in the flake.nix without having to have arion-{compose,pkgs}.nix and you could do cool things like:

arion --flake github:colinxs/arion#arion-foo up

I tried to implement this myself and got about halfway there, but I know nothing about Haskell lol. If someone could help on the Haskell side
I'd be happy to pitch in elsewhere.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions