branch: elpa/nix-mode
commit 7487346812e5bc443e920e4fe26f8c3a8dcd0eac
Author: Matthew Bauer <[email protected]>
Commit: Matthew Bauer <[email protected]>

    Add flake
---
 .github/workflows/test.yml | 19 +++++++++++++++++++
 README.md                  |  2 +-
 default.nix                | 20 ++------------------
 flake.lock                 | 26 ++++++++++++++++++++++++++
 flake.nix                  | 38 ++++++++++++++++++++++++++++++++++++++
 5 files changed, 86 insertions(+), 19 deletions(-)

diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
new file mode 100644
index 0000000000..aabe77207b
--- /dev/null
+++ b/.github/workflows/test.yml
@@ -0,0 +1,19 @@
+name: "Test"
+on:
+  pull_request:
+  push:
+jobs:
+  tests:
+    strategy:
+      matrix:
+        os: [ubuntu-latest, macos-latest]
+    runs-on: ${{ matrix.os }}
+    steps:
+    - uses: actions/checkout@v2
+      with:
+        fetch-depth: 0
+    - uses: cachix/install-nix-action@v10
+    - run: nix build
+     - run: nix-build -E '(import ./. 
{}).defaultPackage.${builtins.currentSystem}'
+    #- run: nix flake check
+    # - run: nix-build -E '(import ./. {}).checks.${builtins.currentSystem}'
diff --git a/README.md b/README.md
index dac1b032ab..99d2329558 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
 [![MELPA 
Stable](https://stable.melpa.org/packages/nix-mode-badge.svg)](https://stable.melpa.org/#/nix-mode)
 [![Build 
Status](https://travis-ci.com/NixOS/nix-mode.svg?branch=master)](https://travis-ci.com/NixOS/nix-mode)
 
-An emacs major mode for editing nix expressions. There is also a
+An Emacs major mode for editing Nix expressions. There is also a
 manual available at nix-mode.org.
 
 ## Submodes
diff --git a/default.nix b/default.nix
index 6b447922d8..71d1a80ad1 100644
--- a/default.nix
+++ b/default.nix
@@ -1,19 +1,3 @@
-{ pkgs ? import <nixpkgs> {}}:
-let
-  inherit (pkgs) emacsWithPackages stdenvNoCC texinfo git;
-  emacs = emacsWithPackages (epkgs: with epkgs; [
-    org-plus-contrib
-    company
-    json-mode
-    mmm-mode
-  ]);
-in stdenvNoCC.mkDerivation {
-  name = "nix-mode";
+(import (fetchTarball 
https://github.com/edolstra/flake-compat/archive/master.tar.gz) {
   src = ./.;
-  nativeBuildInputs = [ emacs texinfo git ];
-  makeFlags = [ "PREFIX=$(out)" ];
-  shellHook = ''
-    echo Run make run to get vanilla emacs with nix-mode loaded.
-  '';
-  doCheck = true;
-}
+}).defaultNix
diff --git a/flake.lock b/flake.lock
new file mode 100644
index 0000000000..f385a9622b
--- /dev/null
+++ b/flake.lock
@@ -0,0 +1,26 @@
+{
+  "nodes": {
+    "nixpkgs": {
+      "locked": {
+        "lastModified": 1595687772,
+        "narHash": "sha256-8HukW/hw+g20I1WrL8QyVftG7WWrSqIDL/z6HFQZyy4=",
+        "owner": "NixOS",
+        "repo": "nixpkgs",
+        "rev": "076c67fdea6d0529a568c7d0e0a72e6bc161ecf5",
+        "type": "github"
+      },
+      "original": {
+        "id": "nixpkgs",
+        "ref": "nixos-20.03-small",
+        "type": "indirect"
+      }
+    },
+    "root": {
+      "inputs": {
+        "nixpkgs": "nixpkgs"
+      }
+    }
+  },
+  "root": "root",
+  "version": 7
+}
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000000..23a1f61002
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,38 @@
+{
+  description = "An emacs major mode for editing Nix expressions";
+
+  inputs.nixpkgs.url = "nixpkgs/nixos-20.03-small";
+
+  outputs = { self, nixpkgs }: let
+    systems = [ "x86_64-linux" "i686-linux" "x86_64-darwin" "aarch64-linux" ];
+    forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system);
+  in {
+    packages = forAllSystems (system: with (import nixpkgs { inherit system; 
}); {
+      nix-mode = let
+        emacs = emacsWithPackages (epkgs: with epkgs; [
+          org-plus-contrib
+          company
+          json-mode
+          mmm-mode
+        ]);
+      in stdenvNoCC.mkDerivation {
+        name = "nix-mode";
+        src = self;
+        nativeBuildInputs = [ emacs texinfo git ];
+        makeFlags = [ "PREFIX=$(out)" ];
+        shellHook = ''
+          echo Run make run to get vanilla emacs with nix-mode loaded.
+        '';
+        doCheck = true;
+      };
+    });
+
+    defaultPackage = forAllSystems (system: self.packages.${system}.nix-mode);
+
+    # checks are run in ‘make check’ right now we should probably move
+    # these to its own derivation
+    checks = forAllSystems (system: {
+      inherit (self.packages.${system}) nix-mode;
+    });
+  };
+}

Reply via email to