diff --git a/DIST b/DIST index fcefcd1..984a68f 100644 --- a/DIST +++ b/DIST @@ -1,9 +1,6 @@ Generate bindist: -arm64 - - hell scripts/static-build.hell --stack-arch aarch64-linux --filename hell-linux-arm64 --ghc-version ghc-9.8.2 --docker-container hell - -amd64 - - hell scripts/static-build.hell --stack-arch x86_64-linux --filename hell-linux-amd64 --ghc-version ghc-9.8.2 --docker-container hell-amd64 + nix build .#static-arm64 -o hell-linux-arm64-dir + cp ./hell-linux-arm64-dir/bin/hell hell-linux-arm64 + nix build .#static-amd64 -o hell-linux-amd64-dir + cp ./hell-linux-amd64-dir/bin/hell hell-linux-amd64 diff --git a/flake.lock b/flake.lock index 36493e8..20db77f 100644 --- a/flake.lock +++ b/flake.lock @@ -5,11 +5,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1726560853, - "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=", + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", "owner": "numtide", "repo": "flake-utils", - "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", "type": "github" }, "original": { @@ -20,16 +20,16 @@ }, "nixpkgs": { "locked": { - "lastModified": 1741037377, - "narHash": "sha256-SvtvVKHaUX4Owb+PasySwZsoc5VUeTf1px34BByiOxw=", + "lastModified": 1776877367, + "narHash": "sha256-EHq1/OX139R1RvBzOJ0aMRT3xnWyqtHBRUBuO1gFzjI=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "02032da4af073d0f6110540c8677f16d4be0117f", + "rev": "0726a0ecb6d4e08f6adced58726b95db924cef57", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixpkgs-unstable", + "ref": "nixos-unstable", "repo": "nixpkgs", "type": "github" } diff --git a/flake.nix b/flake.nix index c850903..cdaa6e4 100644 --- a/flake.nix +++ b/flake.nix @@ -1,32 +1,50 @@ { + description = "hell"; inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; flake-utils.url = "github:numtide/flake-utils"; }; - outputs = { self, nixpkgs, flake-utils }: - flake-utils.lib.eachDefaultSystem (system: + flake-utils.lib.eachSystem [ "aarch64-linux" "x86_64-linux" ] (system: let - pkgs = nixpkgs.legacyPackages.${system}; - overlay = final: prev: { - hell = prev.callCabal2nix "hell" ./. { }; + pkgs = import nixpkgs { inherit system; }; + + pkgsStaticArm64 = import nixpkgs { + localSystem = system; + crossSystem = { + config = "aarch64-unknown-linux-musl"; + isStatic = true; + }; + }; + pkgsStaticAmd64 = import nixpkgs { + localSystem = system; + crossSystem = { + config = "x86_64-unknown-linux-musl"; + isStatic = true; + }; }; - haskellPackages = pkgs.haskell.packages.ghc910.extend overlay; - in - { - # nix build - packages.default = haskellPackages.hell; - # nix develop - devShells.default = haskellPackages.shellFor { - packages = p: [ p.hell ]; - buildInputs = with haskellPackages; [ - stack + mkStaticApp = hp: hp.haskellPackages.callCabal2nix "hell" ./. {}; + + app = pkgs.haskellPackages.callCabal2nix "hell" ./. {}; + in { + devShells.default = pkgs.haskellPackages.shellFor { + name = "hell-dev"; + packages = _: [ app ]; + withHoogle = true; + buildInputs = with pkgs.haskellPackages; [ cabal-install haskell-language-server - pandoc-cli + fourmolu + hlint + pkgs.zlib ]; }; + packages = { + default = app; + static-arm64 = mkStaticApp pkgsStaticArm64; + static-amd64 = mkStaticApp pkgsStaticAmd64; + }; } ); } diff --git a/scripts/install-hell.hell b/scripts/install-hell.hell deleted file mode 100644 index 587b0fa..0000000 --- a/scripts/install-hell.hell +++ /dev/null @@ -1,2 +0,0 @@ -main = do - Directory.copyFile "hell-linux-x86-64bit" "/usr/bin/hell" diff --git a/scripts/static-build.hell b/scripts/static-build.hell deleted file mode 100644 index 2af0cf4..0000000 --- a/scripts/static-build.hell +++ /dev/null @@ -1,37 +0,0 @@ -data Opts = Opts { - arch :: Text, - filename :: Text, - ghc :: Text, - container :: Text - } -options = - (\arch filename ghc container -> Main.Opts { arch, filename, ghc, container }) - <$> Options.strOption (Option.long "stack-arch" <> Option.help "x86_64-linux or aarch64-linux") - <*> Options.strOption (Option.long "filename" <> Option.help "e.g. hell-linux-amd64 or hell-linux-arm64") - <*> Options.strOption (Option.long "ghc-version" <> Option.help "e.g. ghc-9.8.2") - <*> Options.strOption (Option.long "docker-container" <> Option.help "e.g. hell or hell-amd64") - -main = do - opts <- Options.execParser (Options.info (Main.options <**> Options.helper) Options.fullDesc) - let arch = Record.get @"arch" opts - let filename = Record.get @"filename" opts - let ghc = Record.get @"ghc" opts - let container = Record.get @"container" opts - let distPath = ".stack-work/dist/" <> arch <> "/" <> ghc <> "/build/hell/" - - Process.runProcess_ (Process.proc "docker" ["exec", container, "stack", "build","--ghc-options", "-static -optl-static -fforce-recomp", "--force-dirty"]) - Directory.copyFile (distPath <> "/hell") filename - Process.runProcess_ (Process.proc "docker" ["exec", container, "strip", filename]) - pwd <- Directory.getCurrentDirectory - env <- Environment.getEnvironment - path <- Environment.getEnv "PATH" - Process.runProcess_ $ - Process.setEnv - (List.cons - ("PATH", - Text.concat - [pwd, - "/" <> distPath, ":", - path]) - env) $ - Process.proc "hell" ["scripts/check.hell"] diff --git a/scripts/static-build.sh b/scripts/static-build.sh new file mode 100755 index 0000000..fa1494f --- /dev/null +++ b/scripts/static-build.sh @@ -0,0 +1,4 @@ +nix build .#static-arm64 -o hell-linux-arm64-dir +cp ./hell-linux-arm64-dir/bin/hell hell-linux-arm64 +nix build .#static-amd64 -o hell-linux-amd64-dir +cp ./hell-linux-amd64-dir/bin/hell hell-linux-amd64 diff --git a/src/Hell.hs b/src/Hell.hs index 61e13d6..01b506e 100644 --- a/src/Hell.hs +++ b/src/Hell.hs @@ -171,7 +171,7 @@ commandParser = -- | Version of Hell. hellVersion :: Text -hellVersion = "2026-04-21" +hellVersion = "2026-04-28" -- | Dispatch on the command. dispatch :: Command -> IO ()