From 4b83ae894ab99b55c67b6629058b3a4fdd8ba0c2 Mon Sep 17 00:00:00 2001 From: Vito Canadi Date: Tue, 14 Aug 2018 12:53:03 +0200 Subject: [PATCH 1/2] NXG-25 Move haskell files to top level --- hs/.gitignore => .gitignore | 0 {hs/cli => cli}/Main.hs | 0 {hs/cli => cli}/Parser.hs | 0 {hs/cli => cli}/Types.hs | 0 {hs/data => data}/stack-shell.nix | 0 default.nix | 7 ++++++- hs/default.nix | 6 ------ {hs/lib => lib}/Nixage/Convert/FromYaml.hs | 0 {hs/lib => lib}/Nixage/Convert/Nix.hs | 0 {hs/lib => lib}/Nixage/Convert/Stack.hs | 0 {hs/lib => lib}/Nixage/Project.hs | 0 {hs/lib => lib}/Nixage/Project/Extensible.hs | 0 {hs/lib => lib}/Nixage/Project/Native.hs | 0 {hs/lib => lib}/Nixage/Project/Types.hs | 0 {hs/lib => lib}/Nixage/Project/Yaml.hs | 0 hs/package.yaml => package.yaml | 0 hs/project.nix => project.nix | 0 hs/shell.nix => shell.nix | 0 18 files changed, 6 insertions(+), 7 deletions(-) rename hs/.gitignore => .gitignore (100%) rename {hs/cli => cli}/Main.hs (100%) rename {hs/cli => cli}/Parser.hs (100%) rename {hs/cli => cli}/Types.hs (100%) rename {hs/data => data}/stack-shell.nix (100%) delete mode 100644 hs/default.nix rename {hs/lib => lib}/Nixage/Convert/FromYaml.hs (100%) rename {hs/lib => lib}/Nixage/Convert/Nix.hs (100%) rename {hs/lib => lib}/Nixage/Convert/Stack.hs (100%) rename {hs/lib => lib}/Nixage/Project.hs (100%) rename {hs/lib => lib}/Nixage/Project/Extensible.hs (100%) rename {hs/lib => lib}/Nixage/Project/Native.hs (100%) rename {hs/lib => lib}/Nixage/Project/Types.hs (100%) rename {hs/lib => lib}/Nixage/Project/Yaml.hs (100%) rename hs/package.yaml => package.yaml (100%) rename hs/project.nix => project.nix (100%) rename hs/shell.nix => shell.nix (100%) diff --git a/hs/.gitignore b/.gitignore similarity index 100% rename from hs/.gitignore rename to .gitignore diff --git a/hs/cli/Main.hs b/cli/Main.hs similarity index 100% rename from hs/cli/Main.hs rename to cli/Main.hs diff --git a/hs/cli/Parser.hs b/cli/Parser.hs similarity index 100% rename from hs/cli/Parser.hs rename to cli/Parser.hs diff --git a/hs/cli/Types.hs b/cli/Types.hs similarity index 100% rename from hs/cli/Types.hs rename to cli/Types.hs diff --git a/hs/data/stack-shell.nix b/data/stack-shell.nix similarity index 100% rename from hs/data/stack-shell.nix rename to data/stack-shell.nix diff --git a/default.nix b/default.nix index 4203ea9..a68c4a6 100644 --- a/default.nix +++ b/default.nix @@ -1 +1,6 @@ -import ./nix +{ exposeNixage ? false }: + +let + nixage = import ./nix { inherit exposeNixage; }; + +in nixage.buildNixProject ./. diff --git a/hs/default.nix b/hs/default.nix deleted file mode 100644 index 2379eba..0000000 --- a/hs/default.nix +++ /dev/null @@ -1,6 +0,0 @@ -{ exposeNixage ? false }: - -let - nixage = import ../nix { inherit exposeNixage; }; - -in nixage.buildNixProject ./. diff --git a/hs/lib/Nixage/Convert/FromYaml.hs b/lib/Nixage/Convert/FromYaml.hs similarity index 100% rename from hs/lib/Nixage/Convert/FromYaml.hs rename to lib/Nixage/Convert/FromYaml.hs diff --git a/hs/lib/Nixage/Convert/Nix.hs b/lib/Nixage/Convert/Nix.hs similarity index 100% rename from hs/lib/Nixage/Convert/Nix.hs rename to lib/Nixage/Convert/Nix.hs diff --git a/hs/lib/Nixage/Convert/Stack.hs b/lib/Nixage/Convert/Stack.hs similarity index 100% rename from hs/lib/Nixage/Convert/Stack.hs rename to lib/Nixage/Convert/Stack.hs diff --git a/hs/lib/Nixage/Project.hs b/lib/Nixage/Project.hs similarity index 100% rename from hs/lib/Nixage/Project.hs rename to lib/Nixage/Project.hs diff --git a/hs/lib/Nixage/Project/Extensible.hs b/lib/Nixage/Project/Extensible.hs similarity index 100% rename from hs/lib/Nixage/Project/Extensible.hs rename to lib/Nixage/Project/Extensible.hs diff --git a/hs/lib/Nixage/Project/Native.hs b/lib/Nixage/Project/Native.hs similarity index 100% rename from hs/lib/Nixage/Project/Native.hs rename to lib/Nixage/Project/Native.hs diff --git a/hs/lib/Nixage/Project/Types.hs b/lib/Nixage/Project/Types.hs similarity index 100% rename from hs/lib/Nixage/Project/Types.hs rename to lib/Nixage/Project/Types.hs diff --git a/hs/lib/Nixage/Project/Yaml.hs b/lib/Nixage/Project/Yaml.hs similarity index 100% rename from hs/lib/Nixage/Project/Yaml.hs rename to lib/Nixage/Project/Yaml.hs diff --git a/hs/package.yaml b/package.yaml similarity index 100% rename from hs/package.yaml rename to package.yaml diff --git a/hs/project.nix b/project.nix similarity index 100% rename from hs/project.nix rename to project.nix diff --git a/hs/shell.nix b/shell.nix similarity index 100% rename from hs/shell.nix rename to shell.nix From 0512da21318aacf4eb9f52036eae24ac4ce4b548 Mon Sep 17 00:00:00 2001 From: Vito Canadi Date: Tue, 21 Aug 2018 16:27:28 +0200 Subject: [PATCH 2/2] Add Haskell source files --- cli/Main.hs | 4 ++-- data/stack-shell.nix | 7 ++++++- nix/yaml.nix | 2 +- package.yaml | 15 +++++++++++++-- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/cli/Main.hs b/cli/Main.hs index 99eda9f..0040085 100644 --- a/cli/Main.hs +++ b/cli/Main.hs @@ -34,7 +34,7 @@ stackAction args = do withSystemTempFile "nixage-stack-snapshot.yaml" $ \snapshotPath snapshotH -> withTempFile "." "nixage-stack.yaml" $ \stackPath stackH -> do withTempFile "." "nixage-stack-shell.nix" $ \stackShellPath stackShellH -> do - stackShellSourcePath <- liftIO $ getDataFileName "stack-shell.nix" + stackShellSourcePath <- liftIO $ getDataFileName "data/stack-shell.nix" let stackFilesInfo = StackFilesInfo snapshotPath stackShellPath stackShellSourcePath "./." liftIO $ hClose stackShellH >> hClose stackH >> hClose snapshotH encodeToStack stackPath stackFilesInfo projectNative @@ -51,7 +51,7 @@ convertAction (ConvertArgs convertIn convertOut) = do YamlConvertIn yamlPath -> decodeFromYaml (toString yamlPath) case convertOut of StackConvertOut stackPath snapshotPath stackShellPath -> do - stackShellSourcePath <- liftIO $ getDataFileName "stack-shell.nix" + stackShellSourcePath <- liftIO $ getDataFileName "data/stack-shell.nix" let stackFilesInfo = StackFilesInfo snapshotPath stackShellPath stackShellSourcePath "./." encodeToStack (toString stackPath) stackFilesInfo projectNative NixConvertOut -> do diff --git a/data/stack-shell.nix b/data/stack-shell.nix index 0faceaa..0203916 100644 --- a/data/stack-shell.nix +++ b/data/stack-shell.nix @@ -1,6 +1,11 @@ root: let - x = import (root + "/default.nix") { exposeNixage = true; }; + defaultNixage = let nixage = import ../nix { exposeNixage = true; }; + in nixage.buildYamlProject root; + projDefaultNix = root + "/default.nix"; + x = if builtins.pathExists projDefaultNix + then import projDefaultNix { exposeNixage = true; } + else defaultNixage; pkgs = x._nixage.pkgs; stackCmd = ''stack --internal-re-exec-version="${pkgs.stack.version}"''; in x._nixage.haskellPackages.shellFor { diff --git a/nix/yaml.nix b/nix/yaml.nix index 33f94ed..51e8fe6 100644 --- a/nix/yaml.nix +++ b/nix/yaml.nix @@ -3,7 +3,7 @@ let inherit (builtins) genList head tail; inherit (pkgs.lib) concatMap concatStrings singleton; - inherit (import ../hs {}) nixage; + inherit (import ../default.nix {}) nixage; in { importYaml = path: diff --git a/package.yaml b/package.yaml index a846306..705e58b 100644 --- a/package.yaml +++ b/package.yaml @@ -58,5 +58,16 @@ executables: ghc-options: - -threaded -data-dir: data -data-files: stack-shell.nix +data-dir: . +data-files: + - default.nix + - project.nix + - package.yaml + - cli/*.hs + - lib/Nixage/*.hs + - lib/Nixage/Convert/*.hs + - lib/Nixage/Project/*.hs + - nix/*.nix + - nix/extraDeps/*.nix + - nix/tools/nix-prefetch-git + - data/stack-shell.nix