diff --git a/flake.lock b/flake.lock index d1703c0..a16c929 100644 --- a/flake.lock +++ b/flake.lock @@ -2,7 +2,9 @@ "nodes": { "fenix": { "inputs": { - "nixpkgs": "nixpkgs", + "nixpkgs": [ + "nixpkgs" + ], "rust-analyzer-src": "rust-analyzer-src" }, "locked": { @@ -52,16 +54,16 @@ }, "nixpkgs": { "locked": { - "lastModified": 1643347846, - "narHash": "sha256-O0tyXF//ppRpe9yT1Uu5n34yI2MWDyY6ZiJ4Qn5zIkE=", + "lastModified": 1643322911, + "narHash": "sha256-WLe4lXAYXH/v80iO02npX1wdXq4nIVEHJTONLXbQrL0=", "owner": "nixos", "repo": "nixpkgs", - "rev": "5bb20f9dc70e9ee16e21cc404b6508654931ce41", + "rev": "d9e21f284317f85b3476c0043f4efea87a226c3a", "type": "github" }, "original": { "owner": "nixos", - "ref": "nixos-unstable", + "ref": "nixpkgs-unstable", "repo": "nixpkgs", "type": "github" } @@ -71,10 +73,7 @@ "fenix": "fenix", "flakeCompat": "flakeCompat", "flakeUtils": "flakeUtils", - "nixpkgs": [ - "fenix", - "nixpkgs" - ] + "nixpkgs": "nixpkgs" } }, "rust-analyzer-src": { diff --git a/flake.nix b/flake.nix index 61ff3fb..c9ddd38 100644 --- a/flake.nix +++ b/flake.nix @@ -1,11 +1,11 @@ { inputs = { + fenix.url = "github:nix-community/fenix"; + fenix.inputs.nixpkgs.follows = "nixpkgs"; flakeCompat.url = github:edolstra/flake-compat; flakeCompat.flake = false; flakeUtils.url = "github:numtide/flake-utils"; - nixpkgs.follows = "fenix/nixpkgs"; - # add https://app.cachix.org/cache/nix-community to your `nix.conf` - fenix.url = "github:nix-community/fenix"; + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; }; outputs = inputs: @@ -13,20 +13,19 @@ ( system: let - toolchain = "stable"; nixpkgs = import inputs.nixpkgs { inherit system; }; cargoToml = builtins.fromTOML ( builtins.readFile ./Cargo.toml ); + fenix = inputs.fenix.packages.${ system }; + fenixPlatform = nixpkgs.makeRustPlatform { inherit ( fenix.latest ) cargo rustc; }; in { - checks = { - defaultPackage = inputs.self.defaultPackage.${ system }; - inherit ( inputs.self.packages.${ system } ) nixpkgsFormatted; + checks = { defaultPackage = inputs.self.defaultPackage.${ system }; }; + defaultApp = { + type = "app"; + program = "${ inputs.self.defaultPackage.${ system } }/bin/alejandra"; }; - defaultApp = { type = "app"; program = "${ inputs.self.defaultPackage.${ system } }/bin/alejandra"; }; defaultPackage = - (nixpkgs.makeRustPlatform { - inherit (inputs.fenix.packages.${ system }.${ toolchain }) cargo rustc; - }).buildRustPackage + fenixPlatform.buildRustPackage { pname = cargoToml.package.name; version = @@ -37,7 +36,6 @@ "${ builtins.substring 0 8 date }_${ commit }"; src = inputs.self.sourceInfo; cargoLock.lockFile = ./Cargo.lock; - NIX_BUILD_CORES = 0; meta = { description = cargoToml.package.description; homepage = "https://github.com/kamadorueda/alejandra"; @@ -49,40 +47,14 @@ nixpkgs.mkShell { packages = [ - inputs.fenix.packages.${ system }.rust-analyzer - (inputs.fenix.packages.${ system }.${ toolchain }.withComponents [ - "cargo" - "clippy" - "rust-src" - "rustc" - "rustfmt" - ]) + fenix.rust-analyzer + fenix.latest.cargo + fenix.latest.clippy + fenix.latest.rust-src + fenix.latest.rustc + fenix.latest.rustfmt ]; }; - packages = { - nixpkgsFormatted = - nixpkgs.stdenv.mkDerivation - { - name = "nixpkgs-formatted"; - builder = - builtins.toFile - "builder.sh" - '' - source $stdenv/setup - - cp -rT $nixpkgs $out - chmod -R +w $out - - alejandra $out - - git diff --no-index $nixpkgs $out > $diff || true - ''; - buildInputs = [ inputs.self.defaultPackage.${ system } nixpkgs.git ]; - nixpkgs = inputs.nixpkgs.sourceInfo.outPath; - NIX_BUILD_CORES = 0; - outputs = [ "diff" "out" ]; - }; - }; } ); } diff --git a/src/builder.rs b/src/builder.rs index d425f3c..7a7b435 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -173,7 +173,7 @@ fn format( rnix::SyntaxKind::NODE_ATTR_SET => crate::rules::attr_set::rule, // a $op b rnix::SyntaxKind::NODE_BIN_OP => crate::rules::bin_op::rule, - // + // ${a} (interpolation but for NODE_SELECT) rnix::SyntaxKind::NODE_DYNAMIC => crate::rules::dynamic::rule, // implementation detail of rnix-parser rnix::SyntaxKind::NODE_ERROR => { @@ -201,7 +201,7 @@ fn format( rnix::SyntaxKind::NODE_LET_IN => crate::rules::let_in::rule, // [ ... ] rnix::SyntaxKind::NODE_LIST => crate::rules::list::rule, - // $literal + // 1 | true | null rnix::SyntaxKind::NODE_LITERAL => crate::rules::default, // let { } rnix::SyntaxKind::NODE_LEGACY_LET => { @@ -231,6 +231,7 @@ fn format( } // implementation detail of rowan rnix::SyntaxKind::NODE_ROOT => crate::rules::root::rule, + // a.b | a.NODE_DYNAMIC rnix::SyntaxKind::NODE_SELECT => crate::rules::select::rule, // "..." || ''...'' rnix::SyntaxKind::NODE_STRING => crate::rules::string::rule,