From 87ff983fcecdcf9f53ba9cb06c4f2298ce27cd94 Mon Sep 17 00:00:00 2001 From: Brian Hicks Date: Thu, 8 Jul 2021 15:54:18 -0500 Subject: [PATCH] convert to a flake --- default.nix | 15 -------------- flake.lock | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 36 ++++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+), 15 deletions(-) delete mode 100644 default.nix create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/default.nix b/default.nix deleted file mode 100644 index 1a1dc76..0000000 --- a/default.nix +++ /dev/null @@ -1,15 +0,0 @@ -{ pkgs ? import { }, ... }: -pkgs.stdenv.mkDerivation { - name = "similar-sort"; - buildInputs = [ pkgs.go ]; - src = ./.; - - buildPhase = '' - env HOME=$(pwd) GOPATH=$(pwd) go build similar-sort.go - ''; - - installPhase = '' - mkdir -p $out/bin - cp similar-sort $out/bin - ''; -} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..de857f1 --- /dev/null +++ b/flake.lock @@ -0,0 +1,60 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1623875721, + "narHash": "sha256-A8BU7bjS5GirpAUv4QA+QnJ4CceLHkcXdRp4xITDB0s=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "f7e004a55b120c02ecb6219596820fcd32ca8772", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "gitignore": { + "flake": false, + "locked": { + "lastModified": 1611672876, + "narHash": "sha256-qHu3uZ/o9jBHiA3MEKHJ06k7w4heOhA+4HCSIvflRxo=", + "owner": "hercules-ci", + "repo": "gitignore", + "rev": "211907489e9f198594c0eb0ca9256a1949c9d412", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1625766998, + "narHash": "sha256-icJ9QwkvdyhJI1vHizOGrshkrzf1K39Zr34Zm3z0vsE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "605634580515f6093d56c69165f67b5c6ad37be9", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "release-21.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "gitignore": "gitignore", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..bcb9d6c --- /dev/null +++ b/flake.nix @@ -0,0 +1,36 @@ +{ + description = "sort lines by their similarity to a candidate string"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs?ref=release-21.05"; + gitignore = { + url = "github:hercules-ci/gitignore"; + flake = false; + }; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = inputs: + inputs.flake-utils.lib.eachDefaultSystem (system: + let + pkgs = inputs.nixpkgs.legacyPackages.${system}; + gitignore = pkgs.callPackage inputs.gitignore { }; + in rec { + packages.similar-sort = pkgs.stdenv.mkDerivation { + name = "similar-sort"; + buildInputs = [ pkgs.go ]; + src = gitignore.gitignoreSource ./.; + + buildPhase = '' + env HOME=$(pwd) GOPATH=$(pwd) go build similar-sort.go + ''; + + installPhase = '' + mkdir -p $out/bin + cp similar-sort $out/bin + ''; + }; + + defaultPackage = packages.similar-sort; + }); +}