Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Nix package #1899

Closed
x80486 opened this issue Jul 26, 2023 · 4 comments
Closed

Create Nix package #1899

x80486 opened this issue Jul 26, 2023 · 4 comments

Comments

@x80486
Copy link

x80486 commented Jul 26, 2023

This is just a "tracking issue" for the one that was created (who did this? 🤣) in the Nix repository, so you are aware of the progress — if it finally gets picked up.

@NotEvenANeko
Copy link

I just made the 0.12.0 of atlas package in my NUR, not sure if it works on Windows.

https://nur.nix-community.org/repos/notevenaneko/

@wlcx
Copy link

wlcx commented Jul 26, 2023

Had a brief look at this today. The below nix derivation almost works, but go mod vendor (as used by nixos' buildGoModule) fails on release 0.12.0 due to an outdated go.sum. Looks like this is fixed on master, so should work next release.

As an aside, is there a reason for the slightly odd structure of this repo? As far as I can tell, due to the cmd/atlas subdirectory having its own go.mod / go.sum, it fetches itself (ariga.io/atlas) as a dependency (due to the imports for ariga.io/atlas/sql I guess?). It looks like the go workspace stuff (go.work, go.work.sum) perhaps addresses this, but I'm not very familar with go workspaces (and they seem under-documented in general...)

{ lib
, buildGoModule
, fetchFromGitHub
}:

buildGoModule rec {
  pname = "atlas";
  version = "0.12.0";

  src = "${fetchFromGitHub {
    owner = "ariga";
    repo = "atlas";
    rev = "v${version}";
    hash = "sha256-BxTgIfqg5AFYvSqf4++wB2SBKEPW1TBC3mb9YpHM0Q4";
  }}/cmd/atlas";

  vendorHash = lib.fakeHash;

  meta = with lib; {
    description = "Database schema management and migration tool";
    longDescription = ''
      Atlas is a language-agnostic tool for managing and migrating
      database schemas using modern DevOps principles.
    '';
    homepage = "https://atlasgo.io";
    license = licenses.asl20;
    maintainers = with maintainers; [ samw ];
  };
}

@NotEvenANeko
Copy link

NotEvenANeko commented Jul 26, 2023

@wlcx

You need modRoot = "cmd/atlas" to set the module root (compile cmd/atlas), and proxyVendor = true.

NixOS/nixpkgs#201531

But the unit tests need something like sed to replace the hardcoded Atlas CLI - development string and remove the logic for BSD sed in darwin because sed in stdenv is GNU sed for now.

@x80486
Copy link
Author

x80486 commented Sep 3, 2023

Nix package is already available.

Would be great if you add this installation source in the (official) Atlas documentation.

@x80486 x80486 closed this as completed Sep 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants